3. int hours, tuition, dorm_plan, meal_plan, SA_fee, Technology_fee, total_fee;
char response;
bool error;
cout << "How many credits hours are you taking this semester? (max = 21) ";
cin >> hours;
do {
if((hours>21)||(hours<0))
{
cout << " That is an invalid credit hour(s). Enter a valid credit hour ";
error = true;
}
}while(error==true);
if(hours>17&&hours>12)
{
tuition = 9828; //Package deal
cout << " Your tuition is $9,828 ";
}
else if (hours>17)
{//increment by 615 every 1 credit after 17
tuition = (hours-17)*615+9828;
cout << " Your tuition is $";
}
else
{
tuition = hours * 819; //Part-time school
cout << " Your tuition is $" << tuition << endl;
}
do{
cout << " A fixed Student Association fee is collected from each" << endl;
cout << " enrolled student for the purpose of operating, maintaining," << endl;
cout << " improving and equipping the Student Association." << endl;
cout << "The Student Association fee is $" << SA_fee << endl;
SA_fee = 110;
} while(error == true);
do{
4. cout << " The technology fee is $" << Technology_fee << endl;
Technology_fee = 200;
} while(error == true);
do {
cout << " Are you staying in the dorm? (yes or no) -->";
cout << " Enter y for yes or n for no. ";
cin >> response;
if(response=='y')
{
cout << " Dorm plan is $1,850 ";
dorm_plan = 1850;
error = false;
}
else if(response=='n')
{
cout << " You don't have a dorm plan ";
dorm_plan = 0;
error = false;
}
else
{
cout << " Invalid character, please try again ";
error = true;
}
} while(error == true);
do {
cout << " Do you have a meal plan? (y or n) -->";
cout << " Enter y for yes or n for no. ";
cin >> response;
if(response=='y')
{
cout << " Meal plan is $1,900 ";
meal_plan = 1900;
error = false;
}
else if(response=='n')
5. {
cout << " You don't have a meal plan ";
meal_plan = 0;
error = false;
}
else
{
cout << " Invalid character, please try again ";
error = true;
}
} while(error == true);
total_fee = tuition + SA_fee + Technology_fee + dorm_plan + meal_plan;
cout << " Your total charge is $" << total_fee << endl;
return total_fee;
}
int f_aid()
{
int choice, hours, n_scholarship;
bool error;
float rate, work_money, scholarship_money, total, scholarship;
choice = aid_menu();
while (choice != QUIT){
if(choice == WORK){
//Scholarships
do {
cout << " How many scholarships have you earned? (Min = 0, Max = 10) ";
cin >> n_scholarship;
if((n_scholarship<0)||(n_scholarship>10))
{
cout << " Invalid number, please try again ";
error = true;
}
else
{
for(int i=1; i<=n_scholarship; i++)
{
6. cout << " Enter amount for scholarship #" << i << " -->";
cin >> scholarship;
scholarship_money += scholarship;
}
cout << " You have added $" << scholarship_money << " to your account";
error = false;
}
} while(error==true);
}
else
{ //Work
do {
cout << " How many hours do you work? (Max = 25) ";
cin >> hours;
if((hours<0)||(hours>25))
{
cout << " The number of hours you enter is invalid, please try again ";
error = true;
}
else
{
do {
rate = 7.25;
work_money = hours * rate * 0.8 * 16;
cout << " You will make $" << work_money << " this semester ";
error = false;
} while(error==true);
error = false;
}
} while(error == true);
}
choice = aid_menu();
}
total = work_money + scholarship_money;
return total;
7. }
int f_menu()
{
int choice;
bool error = false;
cout << endl;
cout << "FINANCIAL AID MENU ";
cout << "1 Scholarships" << endl;
cout << "2 Work" << endl;
cout << "3 Main Menu" << endl;
do{
cout << "Enter a number between 1 and 3: ";
cin >> choice;
if((choice > 3)||(choice < 1))
{
cout << " Invalid number, try again ";
error = true;
}
else
{
error = false;
}
}while(error == true);
return choice;
return 0;
}
Solution
//Main File (usestudentacc.cpp)
#include
#include "studentacc.h"
using namespace std;
int m_menu();
8. int aid_menu();
int f_aid();
int getCharge(); //Different charges for student account
const int AID = 1, BALANCE = 2, QUIT = 3;
const int SCHOLARSHIPS = 1, WORK = 2;
int main()
{
Studentacc sa;
float cash, amount;
int choice, charge, aid;
cout << "Enter the amount availible for payment: $";
cin >> cash;
sa.setBalance(cash);
cout << fixed << showpoint << setprecision(2);
//School Fees
charge = getCharge();
sa.addCharge(charge);
amount = sa.getBalance();
sa.setBalance(amount);
if(amount<0)
{
cout << "You owe $" << (-1) * amount << "this semester" << endl;
}
else
{
cout << "Your balance is $" << amount << endl;
}
choice = m_menu();
while(choice !=QUIT)
{
if(choice == AID)
{
aid = f_aid();
sa.addCharge(amount);
}
10. {
cout << " That is an invalid credit hour(s). Enter a valid credit hour ";
error = true;
}
}while(error==true);
if(hours>17&&hours>12)
{
tuition = 9828; //Package deal
cout << " Your tuition is $9,828 ";
}
else if (hours>17)
{//increment by 615 every 1 credit after 17
tuition = (hours-17)*615+9828;
cout << " Your tuition is $";
}
else
{
tuition = hours * 819; //Part-time school
cout << " Your tuition is $" << tuition << endl;
}
do{
cout << " A fixed Student Association fee is collected from each" << endl;
cout << " enrolled student for the purpose of operating, maintaining," << endl;
cout << " improving and equipping the Student Association." << endl;
cout << "The Student Association fee is $" << SA_fee << endl;
SA_fee = 110;
} while(error == true);
do{
cout << " The technology fee is $" << Technology_fee << endl;
Technology_fee = 200;
} while(error == true);
do {
cout << " Are you staying in the dorm? (yes or no) -->";
cout << " Enter y for yes or n for no. ";
cin >> response;
11. if(response=='y')
{
cout << " Dorm plan is $1,850 ";
dorm_plan = 1850;
error = false;
}
else if(response=='n')
{
cout << " You don't have a dorm plan ";
dorm_plan = 0;
error = false;
}
else
{
cout << " Invalid character, please try again ";
error = true;
}
} while(error == true);
do {
cout << " Do you have a meal plan? (y or n) -->";
cout << " Enter y for yes or n for no. ";
cin >> response;
if(response=='y')
{
cout << " Meal plan is $1,900 ";
meal_plan = 1900;
error = false;
}
else if(response=='n')
{
cout << " You don't have a meal plan ";
meal_plan = 0;
error = false;
}
else
{
12. cout << " Invalid character, please try again ";
error = true;
}
} while(error == true);
total_fee = tuition + SA_fee + Technology_fee + dorm_plan + meal_plan;
cout << " Your total charge is $" << total_fee << endl;
return total_fee;
}
int f_aid()
{
int choice, hours, n_scholarship;
bool error;
float rate, work_money, scholarship_money, total, scholarship;
choice = aid_menu();
while (choice != QUIT){
if(choice == WORK){
//Scholarships
do {
cout << " How many scholarships have you earned? (Min = 0, Max = 10) ";
cin >> n_scholarship;
if((n_scholarship<0)||(n_scholarship>10))
{
cout << " Invalid number, please try again ";
error = true;
}
else
{
for(int i=1; i<=n_scholarship; i++)
{
cout << " Enter amount for scholarship #" << i << " -->";
cin >> scholarship;
scholarship_money += scholarship;
}
cout << " You have added $" << scholarship_money << " to your account";
error = false;
}
13. } while(error==true);
}
else
{ //Work
do {
cout << " How many hours do you work? (Max = 25) ";
cin >> hours;
if((hours<0)||(hours>25))
{
cout << " The number of hours you enter is invalid, please try again ";
error = true;
}
else
{
do {
rate = 7.25;
work_money = hours * rate * 0.8 * 16;
cout << " You will make $" << work_money << " this semester ";
error = false;
} while(error==true);
error = false;
}
} while(error == true);
}
choice = aid_menu();
}
total = work_money + scholarship_money;
return total;
}
int f_menu()
{
int choice;
bool error = false;
cout << endl;
cout << "FINANCIAL AID MENU ";