### Thanks! One more issue

Alright! The only issue I am having with the program now is that it isn't working as it should. 1 through 3 registrants should be 150 per. 4 through 9 should be 100 per and 10 and up should be 90 per. It is charging 150 for every ticket no matter what.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748`` ``````#include #include using namespace std; int main() { //declare variables int numOfRegistrants = 0; int totalRegistrants = 0; int companyCounter = 0; const double rateOne = 150.00; const double rateTwo = 100.00; const double rateThree = 90.00; double chargePerCompany = 0.00; double totalCharge = 0.00; double averageCharge = 0.0; cout << "Enter amount of company's registrants: "; cin >> numOfRegistrants; while (numOfRegistrants >= 0){ totalRegistrants = totalRegistrants + numOfRegistrants; companyCounter += 1;; cout << "Enter amount of next company's registrants (or negative number to stop): "; cin >> numOfRegistrants; } //end while if (numOfRegistrants <= 3){ chargePerCompany = (totalRegistrants) * rateOne; } else if(numOfRegistrants <= 9){ chargePerCompany = (totalRegistrants) * rateTwo; }else if(numOfRegistrants >= 10){ chargePerCompany = (totalRegistrants) * rateThree; } //end ifs totalCharge = chargePerCompany; averageCharge = totalCharge / totalRegistrants; //display the data cout << fixed << setprecision (2) << endl; cout << "Total people registered: " << totalRegistrants << endl; cout << "Grand total charges: \$" << totalCharge << endl; cout << "Average charge per registrant: \$" << averageCharge << endl; return 0; }``````
companyCounter is not being used?
Have you tried stepping through it with a debugger, to find out exactly what the values of the variables are at each step in the execution of the program?
Q: What do we know about `numOfRegistrants` after line 25 (i.e. when the loop is over)?
A: That `numOfRegistrants >= 0` is `false`.

Q: Which branch of the `if else ..` is selected, when `numOfRegistrants < 0`?
A: Is that really the way the program should decide?
Topic archived. No new replies allowed.