I made some additions and comments. i sugegst you look at what i did so you know how to do it
Code:
// Don Salzler
// Proj2.cpp
// Program for calculating cost of visitors to amusement park
// CodeWarrior
#include <iostream>
using namespace std;
// This function simply calculates the total cost for children
float CalcChild(int NumChild) {
return NumChild * 2;
}
// This function calculates the total number of free Youths and figures cost based on that
float CalcYouth(int NumYouth) {
int DivFour = NumYouth / 4;
return (NumYouth - DivFour) * 8.50;
}
//This function calculates cost if family has in excess of 10 adults, if if they dont't
float CalcAdult(int NumAdult) {
float Total;
if (NumAdult > 10) {
Total = ((NumAdult - 10) * 9) + 125;
}
else {
Total = NumAdult * 12.50;
}
return Total;
}
int main(int argc, char* argv[])
{
int child, youth, adult;
char any;
const double CHILDPR = 2.00;
const float YOUTHPR = 8.50;
const float ADULTPR = 12.50;
float CostChild, CostYouth, CostAdult;
cout <<" Don's Amusement Ticket Entry\n";
cout <<" ------------------------------\n\n";
cout <<" Enter number of children under 8: ";
cin >> child;
cout <<" Enter number of youth 8-18: ";
cin >> youth;
cout <<" Enter number of adults: ";
cin >> adult;
cout <<""<<endl <<endl <<endl;
// Calculating each cost
CostChild = CalcChild(child);
CostYouth = CalcYouth(youth);
CostAdult = CalcAdult(adult);
cout <<" Don's Amusement Park\n\n";
cout <<" Category Tickets Price Total\n";
cout <<" -------- ------- ----- -----\n";
cout <<" Children Under 8 "<<child <<" $2.00" <<" $" <<CostChild<<endl;
cout <<" Youth 8-18 "<<youth <<" $8.50*" " $" <<CostYouth <<endl;
cout <<" Adults 19+ "<<adult <<" $12.50**"" $" <<CostAdult <<endl;
cout <<" -------\n";
cout <<" " <<child+youth+adult <<endl;
cout <<" -----\n";
if (child + youth + adult >= 20){ // in event theres20 or more poeple
cout <<" Total Bill: " <<" $" <<CostChild + CostYouth + CostAdult + 25<<"***" <<endl <<endl;
}
else { // otherwise
cout <<" Total Bill: " <<" $" <<CostChild + CostYouth + CostAdult <<endl <<endl;
}
cout <<" *One person is free for every 4 tickets in this age group\n";
cout <<" **The price is $9 per adult in excess of 10 adults\n";
if (child + youth + adult >= 20){ // Gota let em know about the fee
cout<<" ***A $25 security fee has been attached as you have 20 or more people\n";
}
cin >> any;
return 0;
}