Ask Experts Questions for FREE Help !
Ask

An array

Asked Oct 11, 2007, 08:52 AM — 1 Answer
How many ratings do you wish to enter? 10
Rating #1: 9
Rating #2: 5
Rating #3: 9
Rating #4: 2
Rating #5: 11
Invalid entry, score must be in range of 1 and 10; try again.
Rating #5: -1
Invalid entry, score must be in range of 1 and 10; try again.
Rating #5: 8
Rating #6: 8
Rating #7: 9
Rating #8: 7
Rating #9: 9
Rating #10: 8
Here are the results:

10 ratings entered
Rating Frequency Percentage
===============================
1 0 0%
-------------------------------
2 1 10%
-------------------------------
3 0 0%
-------------------------------
4 0 0%
-------------------------------
5 1 10%
-------------------------------
6 0 0%
-------------------------------
7 1 10%
-------------------------------
8 3 30%
-------------------------------
9 4 40%
-------------------------------
10 0 0%
-------------------------------

This is how this program should look like. Can some one tell me how to get the part of frequency and percentage. I am having trouble coming with a solution. This is what I have so far #include <iostream>
#include <string>
#include <iomanip>
Using namespace std;

Const int Num_Rating = 10;
Void main(void)
{
auto int userArray[Num_Rating];
auto int index;
auto int Frequency;
auto int Percentage;


cout << "How many ratings do you wish to enter? " << Num_Rating << endl;

for((index = 0); index < Num_Rating; ++index)
{
cout << "Rating #" << index << ":";
cin >> userArray[index];
}
if( index > Num_Rating)
{
cout << "Invalid entry, score must be in range of 1 to 10, try
again.";
cout << "Rating #" << index << ":";
cin >> userArray[index];

}
Frequency =
Percentage =
cout << "Here are the results:

";
cout << "Rating Frequency Percentage" << endl;
cout << "=================================" << endl;
cout << "1 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;
cout << "2 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;
cout << "3 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;
cout << "4 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;
cout << "5 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;
cout << "6 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;
cout << "7 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;
cout << "8 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;
cout << "9 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;
cout << "10 " << Frequency << Percentage << endl;
cout << "---------------------------------" << endl;

} // end of "main"
PLEASE HELP ME THANK YOU

1 Answer
asterisk_man's Avatar
asterisk_man Posts: 476, Reputation: 175
Full Member
 
#2

Oct 15, 2007, 10:12 AM
Is your problem the format for the frequency and percentage?
Have you tried:
Cout << "1 " << Frequency << " " << Percentage << endl;
Helpful

Not your question? Ask your question View similar questions

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Add your answer here.

Remove Text Formatting

Undo
Redo
 
Decrease Size
Increase Size
Bold
Italic
Underline
Align Left
Align Center
Align Right
Ordered List
Unordered List
Decrease Indent
Increase Indent
Insert Email Link
Wrap [QUOTE] tags around selected text
Wrap [CODE] tags around selected text
Wrap [HTML] tags around selected text
Wrap [PHP] tags around selected text
Wrap [YOUTUBE] tags around selected text
Notification Type:



Check out some similar questions!

Code to define array [ 1 Answers ]

I am trying to create a program to define an arry that will hold 50 prices and another Program a double method that returns quotient of two numbers. (quotient = num2/num1) Can somebody help I just need the codes.

Java: using an array from the main in a method [ 2 Answers ]

I have the array names in the main of my program and I want to use it in a method FindName.. How would I wright the method header and the call to the method in the main?

Java Error: array required, but PRmList found [ 2 Answers ]

Here is my code: I get the error: Array required, but PRmList found. Any help would be GREATLY appreciated. Thanks! Public class PRm { private String PRm; private String movieTitle; private String movieRating; private int seats;


View more C++ questions Search