#include <iostream>#include <iomanip>using namespace std; /*Constants*/ const int maxHours = 774; //ISP Plan A. const double monthlyRate_A = 9.95; const double freeHours_A = 10.00; const double hourlyRate_A = 2.00; //ISP Plan B. const double monthlyRate_B = 14.95; const double freeHours_B = 20; const double hourlyRate_B = 1.00; //ISP Blan C, unlimited service. Requires //no other constants than flat service rate. const double monthlyRate_C = 19.95;/*Function main*/int main(){ /*Variables*/ int hours = 0; int month = 0; double monthlyBill_A = 0; double monthlyBill_B = 0; double monthlyBill_C = 0; double possibleSavings = 0; int menuSelection = 1; while (menuSelection != 4) { //Wash and rinse just in case.. hours = 0; /*Menu Selections*/ cout << "\n\nISP Finance Software"; cout << "\n1) Plan A"; cout << "\n2) Plan B"; cout << "\n3) Plan C"; cout << "\n4) Quit\n"; //Prompt for a menu selection cout << "\nEnter a number please :"; cin >> menuSelection; //A quick check for a valid menu selection. while (menuSelection < 1 || menuSelection >4) { cout << "\nInvalid menu entry. \nTry again:"; cin >> menuSelection; } //Ask for the hours and billing month // only for plan A and B. if (menuSelection == 1 || menuSelection == 2) { cout << "\nHow many hours to be billed? :"; cin >> hours; cout << "\nWhat month is being billed? :"; cin >> month; //When computing plan A and B, check that // the number of hours does not exceed // those in a month. Months are numerically // represented. switch (month) { //Months with 774 hours (31 days) case 1: //January case 3: //February case 5: //May case 7: //July case 8: //August case 10://October case 12://December if (hours > 744) (hours = 744); break; //Months with 720 hours (30 days) case 4: //April case 6: //June case 9: //September case 11://November if (hours > 720) (hours = 720); break; case 2://February if (hours > 672) (hours = 672); break; } } //Compute bills for all service plans. This //will allow comparison between them for //possible savings. /* PLAN "A" */ monthlyBill_A = (monthlyRate_A + (hours - freeHours_A) * hourlyRate_A); //Flat rate checker. //This fixes the bill if hours stay within the plan. if (monthlyBill_A <= 0) monthlyBill_A = monthlyRate_A; /* PLAN "B" */ monthlyBill_B = (monthlyRate_B + (hours - freeHours_B) * hourlyRate_B); //Check for a flat rate charge. if (monthlyBill_B <= 0) monthlyBill_B = monthlyRate_B; /* PLAN "C" */ monthlyBill_C = monthlyRate_C; //Plan C is unlimited; //Show the monthly bill as selected, and the possible // savings with another plan. switch (menuSelection) { //Setup formatting. cout << setprecision(2) << fixed; //Plan "A" case 1: { //Show the bill. cout << "\nBill is $" << monthlyBill_A; //Compare to Plan B... if (monthlyBill_A > monthlyBill_B) cout << "\n$" << monthlyBill_A - monthlyBill_B << " could have been saved with plan B"; //...then C. if (monthlyBill_A > monthlyBill_C) cout << "\n$" << monthlyBill_A - monthlyBill_C << " could have been saved with plan C"; break; } //Plan "B". case 2: { //Show the bill cout << "\nBill is $" << monthlyBill_B; //Compare to Plan A... if (monthlyBill_B > monthlyBill_A) cout << "\n$" << monthlyBill_B - monthlyBill_A << " could have been saved with plan A"; //..then C. if (monthlyBill_B > monthlyBill_C) cout << "\n$" << monthlyBill_B - monthlyBill_C << " could have been saved with plan C"; break; } //Plan "C". case 3: { //Show the bill. cout <<"\nBill is $" << monthlyBill_C; //Display savings from plan B or A if ideal. if (monthlyBill_C - monthlyBill_A > 0) cout << "\n$" << monthlyBill_C - monthlyBill_A << " could have been saved with plan C"; if (monthlyBill_C - monthlyBill_B > 0) cout << "\n$" << monthlyBill_C - monthlyBill_B << " could have been saved with plan B"; } break; //Quit. case 4: cout << "\nBye-bye!\n"; break; } } return 0;}