Saturday, May 22, 2010

Help with C++ please! my program is not working why? please help me! To start with, i get alot errors...?

this is the set of number that i am supposed to check it with: 3 registrants by the first company, 12 by the second one 9 for the third one.


#include %26lt;iostream%26gt;





using std::cout;


using std::cin;


using std::endl;


int main()


{


//declare variables


int registrants = 0;


double fee = 0.0;


int totalPeople = 0;


double totalCharge = 0.0;


double average = 0.0;





//get input from the user


cout %26lt;%26lt; "Enter number of registrants (Enter 0 to stop the program): ";


cin %26gt;%26gt; registrants;





//get the registration information for programming seminars


while (registrants != 0)


{


if (registrants %26gt;= 1 %26amp;%26amp; registrants %26lt;= 3)


cout %26lt;%26lt; "Enter number of registrants: " %26lt;%26lt; fee = 150 %26lt;%26lt; endl;


else if (registrants %26gt;= 4 %26amp;%26amp; registrants %26lt;= 9)


cout %26lt;%26lt;"Enter number of registrants: " %26lt;%26lt; fee = 150 %26lt;%26lt; endl;


else


cout %26lt;%26lt;"Enter number of registrants: " %26lt;%26lt; fee = 150 %26lt;%26lt; endl;


} //end ifs

Help with C++ please! my program is not working why? please help me! To start with, i get alot errors...?
I can't quite understand your assignment.





It sounds to me like what you are supposed to do is collect the number of registrants for an unknown number of companies, calculate each company's cost, and output the amount for each company, plus a running total of all costs.





#include %26lt;iostream%26gt;


using namespace std;





int main () {


int registrants = 1;


double fee = 150.00;


double subtotal;


double total;


int i = 1;





while (registrants %26gt; 0) {


cout %26lt;%26lt; "Enter total number of registrants for company " %26lt;%26lt; i %26lt;%26lt; " (enter 0 to end program) %26lt;%26lt; endl;


cin %26gt;%26gt; registrants;





if(registrants %26gt; 0) {


subtotal = registrants * fee;


total += subtotal;





cout %26lt;%26lt; "Total for company " %26lt;%26lt; i %26lt;%26lt; ": " %26lt;%26lt; subtotal %26lt;%26lt; endl;


i++;


}


}





cout %26lt;%26lt; "Grand total for all companies: " %26lt;%26lt; total %26lt;%26lt; endl;





return true;


}


No comments:

Post a Comment