Ask Experts Questions for FREE Help !
Ask
    Crispy's Avatar
    Crispy Posts: 2, Reputation: 1
    New Member
     
    #1

    Oct 11, 2007, 08:52 AM
    an array
    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:\n\n";
    cout << "Rating\t\tFrequency\t\tPercentage" << endl;
    cout << "=================================" << endl;
    cout << "1\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;
    cout << "2\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;
    cout << "3\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;
    cout << "4\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;
    cout << "5\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;
    cout << "6\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;
    cout << "7\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;
    cout << "8\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;
    cout << "9\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;
    cout << "10\t\t" << Frequency << Percentage << endl;
    cout << "---------------------------------" << endl;

    } // end of "main"
    PLEASE HELP ME THANK YOU
    asterisk_man's Avatar
    asterisk_man Posts: 476, Reputation: 32
    Full Member
     
    #2

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

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


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 questions Search