changes you must make and why
==========================

Code:
#include <iostream>
#include <iomanip>
using namespace std;//use this method its better

int main(){
 //declare variables
 char company1[80];//use this trick to avoid problems with input data
 char company=' ';
 int registrantCount = 0;  //it holds all registrants from all companies
 int registrants = 0;  //it holds the registrants for a single company
 double chargePerson = 0.0;
 double totalCharge = 0.0; //accumulator
 double averageCharge = 0.0;
 //int y = 0;     //counter you do not need it
 double subCharge = 0.0;
 
 //convert variable types
 static_cast <double> (registrantCount);
 cout << fixed << setprecision (2);

 
 //enter number of registrants
 while (company != 'S' && company != 's'){
    //enter company
     cout << "Enter company: ";//inside the while we must read again the company name otherwise there is no chance the program to exit some time
     cin >> company1;//we read a string
     company=company1[0];//and take only the first char,so if i enter company-->abc company will be a only
     if (company != 'S' && company != 's'){//we use it again in order not to proccess the code below since the program must stop if company='S' or 's'
         cout << "Enter number of registrants: ";
         cin >> registrants;
         //choose cost per registrant
         if (registrants > 0 && registrants < 4){
              chargePerson = 150;
              registrantCount+=registrants;//with this we find the total registrants for all companies
              subCharge = registrants * chargePerson;
              totalCharge+=subCharge;
         }
         else if (registrants >= 4 && registrants<= 9){
              chargePerson = 100;
              registrantCount+=registrants;
              subCharge = registrants* chargePerson;
              totalCharge+=subCharge;
         }
         else if (registrants>= 10) {
              chargePerson = 90;
              registrantCount+=registrants;
              subCharge = registrants*chargePerson;
              totalCharge +=subCharge;
         }
         else if (cin.fail()){//with this you trap errors related with bad input,string instead of number              
              cerr << "Incorrect data!!!" << endl;
              cin.clear();
              cin.ignore(numeric_limits<int>::max(),'\n');
         }
         //end ifs
      }
  } //end while
 //display output items
 cout << "Total number of registrants: " << registrantCount << endl;
 cout << "Total amount charged: " << totalCharge << endl;
 averageCharge = totalCharge/registrantCount;
 cout << "Average charge per person: " << averageCharge << endl;
 return 0;
}   //end of main function

Last edited by virxen; 17Mar2010 at 14:45..