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
|
#include <iostream>
#include <iomanip>
void Header()
{
std::cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n";
std::cout << "@@@@@@@@@ APEX AUTO RENTALS @@@@@@@@@ \n";
std::cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n";
std::cout << "\n";
}
int main() {
int miles, Days, amount, costc{ 17 }, costl{ 20 }, weeks, weeklycostc{ 145 }, weeklycostl{ 199 }, mpgc{ 30 }, mpgl{ 16 }, savedc, savedl;
char cartype;
//Header function being called
Header();
std::cout << "Please enter the following information: \n";
std::cout << "\n";
// Prompt user to enter type of car
do {
std::cout << "What class of car would you like? (C for compact L for Luxury):\n";
std::cin >>cartype;
switch (cartype) {
case 'c':
amount = 17;
break;
case 'l':
amount = 20;
break;
default:
std::cout << "invalid entry please try again" << cartype << "\n";
break;
}
}
// while function repeats if input is not c,C,l,L
while ((cartype != 'c') && (cartype != 'l'));
// prompt user to input miles estimate
std::cout << "How many miles will you drive? \n";
std::cin >> miles;
// prompt user to input Days
std::cout << "How many days will you be gone? \n";
std::cin >> Days;
// function to calculate weeks
weeks = Days / 7;
//functions to calculate weekly costs
savedc = ((costc * Days) + (0.28 * miles)) - ((weeklycostc * ceil(Days/7)) + ((miles * 0.28) / 30));
savedl = ((costl * Days) + (0.33 * miles)) - ((weeklycostl * ceil(Days/7)) + (miles * 0.33 / 16));
// display projected Daily cost
if (cartype == 'c') {
std::cout << "Projected cost of Daily Plan: " << (costc * Days) + (0.28 * miles) << "\n";
}
else if (cartype == 'l') {
std::cout << "Projected cost of Daily Plan: " << (costl * Days) + (0.33 * miles) << "\n";
}
// if Days greater than or = 7 than display weekly calculation
if (Days >= 7) {
if (cartype == 'c') {
std::cout << "Projected cost of weekly plan: " << (weeklycostc * ceil(Days / 7)) + ((miles * 0.28)/30) << "\n";
std::cout << "Customer will save " << savedc << " by choosing the Weekly Plan \n";
}
else if (cartype == 'l') {
std::cout << "Projected cost of weekly plan: " << (weeklycostl * ceil(Days / 7)) + ( miles * 0.33/16) << "\n";
std::cout << "\n";
std::cout << "Customer will save " << savedl << " by choosing the Weekly Plan \n";
}
std::cout<<"Number of weeks:" << ceil(Days / 7.0);
}
}
|