Computer problems,Computer help
*AX SOFT>>>Programming & Design

C++ help please!?


i have this table first:
if number of registrants = 1- 3, charge price = 150.
if number of registrants = 4 - 9, charge price = 100
if number of registrants = 10 or more, charge price = 90
this is what it should do but is not working why?
the program should display the total number of people registered, the total charge, and the average charge per registrant. this is my code:
#include <iostream>

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 << "Enter number of registrants (Enter 0 to stop the program): ";
cin >> registrants;

//get the registration information for programming seminars
while (registrants != 0)
{
if (registrants >= 1 && registrants <= 3)
fee = 150;
else if (registrants >= 4 && registrants <= 9)
fee = 100;
else if (registrants > 10)
fee = 90;

this the rest of my code:
}
//display output
cout <<"Total people: ";
cin >> totalPeople;
totalPeople = registrants;

cout <<"Total Charge: ";
cin >> totalCharge;
totalCharge = registrants * fee;

cout <<"Average: ";
cin >>average;
average = totalCharge / registrants;

return 0;
} //end of main function

#include <iostream>
using namespace std;

int main() {
int people = 1;
int fee = 0;
int totalpeople = 0;
int totalfee = 0;

while(people > 0) {
cout << "Enter number of registrants for this company (Enter 0 to exit): << endl;
cin >> people;

if(people > 9) {
fee = 90;
}
elseif(people > 3) {
fee = 100;
}
else {
fee = 150;
}

totalpeople += people;
totalfee += (people * fee);
}

cout << "Total people attending: " << totalpeople << endl;
cout << "Total fees collected: " << totalfees << endl;
cout << "Average fee per person: " << totalfees / totalpeople << endl;

return 0;
}

this is the version which i think should work..
//get input from the user
cout << "Enter number of registrants (Enter 0 to stop the program): ";
cin >> registrants;

//get the registration information for programming seminars
while (registrants != 0)
{
if (registrants >= 1 && registrants <= 3)
fee = 150;
else if (registrants >= 4 && registrants <= 9)
fee = 100;
else
fee = 90;

//get input from the user
cout << "Enter number of registrants (Enter 0 to stop the program): ";
cin >> registrants;

}

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • I have to write a C++ program...?

    This logic will compute the dollars, quarters, etc. You can add it to your programme. int pennies; int dollars; int quarters; int nickles; int dimes; dollars = pennies/100; pennies -= d...

  • I have vista, how do i get my desktop to be a slideshow?

    1.) RIGHT CLICK on your desktop 2.) Click on PERSONALIZE 3.) Click SCREEN SAVER 4.) Click on PHOTOS and choose which folder you would like to display as a slideshow [if you need to, make a separ...

  • Why isn't this website working?

    possibly its not reconizing the OS. i assume their is a PHP script here on this site that is checking for the operating system version and denying clients that dont have XP or VISTA. why? its a ...

  • How do I display more than one column from a php while loop calling one field?

    In this example a table is used: // here you can set the number of columns $numOfCols = 3; // this is a counter $numOfEntries = 0; echo "<table>"; while( ... ) { // f...

  • What are some great bit torrent sites?

    ck out {Kceasy} download it from the filesharing place.

    ...
  • Does Gimp 2.4.4 work on vista?

    yeah it will work. how much ram do you have? in the my computer thing it should tell you the ram. im only 15 years old but i know the technical field very well, for graphic designers you need...

  • Palindrome Words in Javascript?

    <html> <head> <!-- No matter which you select as "best answer" - pick one. --> <script> function get(eid) { var d = document; var r = d.getElementById(e...

  • I need to no a free website or program where i can edit photos? Like i want to make a photo into a puzl photo?

    The Gimp is a great image editing program! It's a lot like photoshop except $700 cheaper. It's a free program and you can download it straight from ...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster