designing a simple movie rating guide program

Hi I'm having trouble with a programming assignment. I'm still a huge beginner at C++. The assignment is to design a program for a movie rating guide. Each theater patron enters a value from 0 to 4 indicating the number of stars the patron awards to the guide's featured movie of the week. The program is supposed to execute continuously until a negative number is entered to quit. At the end of he program, it should display the average star rating of a movie.
This is what I have so far. I'm having trouble with the while loop part because I think my logic is incorrect somewhere in there. Should I use a different sentinal value?? It lets me enter one value but it doesn't let me continue after that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <string>
using namespace std;

int main()
{

   // Declare and initialize variables.
   double numStars;         	 // star rating.
   double averageStars;  	 // average star rating.
   double totalStars = 0; 	 // total of star ratings.
   int numPatrons = 0;           // keep track of number of patrons


   // This is the work done in the housekeeping() function
   // Get input.
   cout << "Enter rating for featured movie: ";
   cin >> numStars;

   // This is the work done in the detailLoop() function
   // Write while loop here
    while (numStars >= 0)
    {
        totalStars = numStars++;
        numPatrons++;
        averageStars = totalStars / numPatrons;
    }
   // This is the work done in the endOfJob() function
   cout << "Average Star Value: " << averageStars << endl;
   cin >> numStars;
   return 0;
} // End of main() 


Any help would be greatly appreciated.
it doesnt let you continue because of your while loop... what you told him is to do this loop while numStars are equal or greater than 0 and numStar will be always greater or equal to 0 because whenever you input that number it is stuck in there.. try to put negative number and see what happens .. it skips the loop.. but it is not what you want. you should try do while loop. include line 17 and 18 inside of loop.
and i give you little hint :line 24 should be like totalStars += numStars;... this way it wil always add to totalStars what is in numStars. numStars++ will add +1 to numStars so if numStars is 5 after numStars++ it will be 6.. let me know if you need any help..
you need to add
1
2
cout << "Enter rating for featured movie: ";
   cin >> numStars;
at the end of your loop so the program keeps asking you to put in a rating. Hope this helped!
Thank you very much to you both. It was very helpful :)
Topic archived. No new replies allowed.