I actually think I understand that now. I did rewrite the program at work today. However, when I tried to execute it, the program does nothing except display "press any key to continue." I do and the window closes. I'm not sure if I did something wrong or if my Microsoft Visual Studio program is acting up. Would someone look at my program and tell me if I have done anything to keep it from running. See program below:
Code:
 
//Ch7AppE04.cpp
//Displays registration information
//Created/revised by <your name> on <current date>
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::setprecision;
int main()
{
 //declare variables
 char company = ' ';
 int registrantCount = 0;  
 double chargePerson = 0.0;
 double totalCharge = 0.0; //accumulator
 double averageCharge = 0.0;
 int y = 0;     //counter
 double subCharge = 0.0;
 //convert variable types
 static_cast <double> (registrantCount);
 cout << fixed << setprecision (2);
 //enter company
 cout << "Enter company: ";
 cin >> company;
 //enter number of registrants
 while (company != 'S' && company != 's')
 {
  cout << "Enter number of registrants: ";
  cin >> registrantCount;
 //choose cost per registrant
 if (registrantCount > 0 && registrantCount < 4)
 {
  chargePerson = 150;
  subCharge = registrantCount * chargePerson;
  totalCharge = totalCharge + subCharge;
 }
 else if (registrantCount >= 4 && registrantCount <= 9)
 {
  chargePerson = 100;
  subCharge = registrantCount * chargePerson;
  totalCharge = totalCharge + subCharge;
 }
 else if (registrantCount >= 10)
 {
  chargePerson = 90;
  subCharge = registrantCount * chargePerson;
  totalCharge = totalCharge + subCharge;
 }
 else
 {
  cout << "Incorrect data" << endl;
  y += 1;
 }
 //end ifs
 } //end while
 //display output items
 cout << "Total number of registrants: " << y << endl;
 cout << "Total amount charged: " << totalCharge << endl;
 average = totalCharge/y;
 cout << "Average charge per person: " << average << endl;
 return 0;
}   //end of main function

Last edited by shabbir; 17Mar2010 at 09:14.. Reason: Code blocks