1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
using namespace std;
//function prototypes
void welcome();
void splash();
void billSummary(int,const double,string);
int summary(int,double);
int menu();
int getNumber();
//variables
int count = 0;
double total = 0;
//enumerator
enum{Adult = 1, Family, Student, Senior, Exit};
//global constants
const double TAX_RATE = 0.075;
const double ADULT = 50;
const double FAMILY = 75;
const double STUDENT = 30;
const double SENIOR = 35;
int main(int argc, char *argv[])
{
int number;
int month, adult, family, student, senior, choice;
//multiple variable statement
adult = family = student = senior = 0;
//function calls
splash();
welcome();
do
{
choice = menu();
int count;
system("CLS");
cout << down12;
switch (choice)
{
case Adult:
do
{
system("CLS");
count += 1;
number = getNumber();
total += number;
}while(month < 0);
number;
billSummary(number,ADULT,"Adult");
break;
case Exit:
cout << over3
<< "You selected EXIT. Have a nice day!" << endl;
summary(count,total);
break;
default:
cout << over3 << choice
<< " is an invalid menu option!!! " << endl
<< down1 << over3 <<"Please try again." << endl;
cout << down10;
}
system("PAUSE");
}while(choice != Exit);
return EXIT_SUCCESS;
}
int getNumber()
{
int number;
system("CLS");
cout << down10 << over3 << "How many months do you want to join? ";
cin >> number;
while(number < 0)
{
system("CLS");
cout << down10 << over3 << number << " is invalid!" << endl;
cout << over3 << "How many months do you want to join? ";
cin >> number;
}
return number;
system("PAUSE");
}
int menu()
{
//input section
int choice;
system("CLS");
cout << down5
<< over3 << "/----------------------------\\ " << endl
<< over3 << "|| Gym Membership Menu ||" << endl
<< over3 << "||__________________________||" << endl
<< over3 << "||**************************||" << endl
<< over3 << "|| \t1. Adult ||" << endl
<< over3 << "|| \t2. Family ||" << endl
<< over3 << "|| \t3. Student ||" << endl
<< over3 << "|| \t4. Senior ||" << endl
<< over3 << "|| \t5. Exit ||" << endl
<< over3 << "\\----------------------------/ " << endl;
cout << down1 << over4 << "Your Choice: ";
cin >> choice;
return choice;
}
void billSummary(int months,double cost,string type)
{
//local variables
double subtotal,tax,total;
//processing
subtotal = months * cost;
tax = subtotal * TAX_RATE;
total = subtotal + tax;
cout << showpoint << setprecision(2) << fixed;
//output section - totals
system("CLS");
cout << setprecision(2) << fixed;
cout << down8;
cout << over3 << type << " Membership Summary Bill " << endl
<< over3 << "---------------------------------" << endl
<< over3 << " Months of Membership: " << setw(7) << months << endl
<< over3 << " Monthly Fee: $" << setw(7) << cost << endl
<< over3 << " Subtotal: $" << setw(7) << subtotal << endl
<< over3 << " Tax: $" << setw(7) << tax << endl
<< over3 << "---------------------------------" << endl
<< over3 << " Total: $" << setw(7) << total << endl
<< down8;
}
int summary(int months,double total)
{
int cost, number, adult, family, student, senior;
int count = 0;
double totalMonths, totalFees;
total = cost * months;
months = count += number;
totalMonths = months;
totalFees += total;
system("CLS");
cout << down10
<< down3 << over3 << "ADULT\tFAMILY\tSTUDENT\tSENIOR" << endl;
cout << over3 << "-----\t------\t-------\t------" << endl;
cout << over3 << setw(3) << adult << "\t" << setw(4) << family << "\t"
<< setw(4) << student << "\t" << setw(4) << senior << endl;
cout << down3 << over3 << "Total Months: " << count << endl;
cout << down3 << over3 << "Total Fees: " << total << endl;
cout << down12;
}
|