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
|
#include<iostream>
#include<cctype>
using namespace std;
int main()
{
char carType,upgrade;
int A, B, C;
char keepgoing;
char condition;
double miles, per_miles;
double days, per_days,new_char;
double price, fees, charges,discount, new_charges;
do
{
do
{
cout<<"Which car are you shopping for? (enter A, B, C)?"<<endl;
cin>>carType;
}while (carType != 'A' && carType != 'B' && carType != 'C' );
cout<<"What condition? (S, O, or, P)"<<endl;
cin>>condition;
if ((condition !='S') || (condition !='O') || (condition !='P'));
else
cout<<"Please enter the correct response"<<endl;
cout<<"How many miles?"<<endl;
cin>>miles;
cout<<"How many days?"<<endl;
cin>> days;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
switch(carType)
{
case 'A':
per_miles = miles * 0.10;
per_days = days * 29.95;
price = per_miles + per_days;
break;
case 'B':
per_miles = miles * 0.15;
per_days = days * 35.95;
price = per_miles + per_days;
break;
case 'C':
per_miles = miles * 0.20;
per_days = days * 39.95;
price = per_miles + per_days;
break;
default:
cout<<"You entered an incorrect car choice"<<endl;
}
if(condition =='O')
{
fees = price * 0.10;
charges = price - fees;
cout<<"The charges are?"<<charges<<endl;
}
else if (condition == 'P')
{
fees = price * 0.10;
charges = price + fees;
cout<<"The charges are?"<<charges<<endl;
}
else
{
cout<<"The charges are?"<<price<<endl;
}
if (condition =='S')
{
fees = charges * 0.10;
new_charges = charges + fees;
discount = new_charges * 0.05;
upgrade = new_charges - discount;
cout<<"You may upgrade for a total cost of $"<<upgrade<<endl;
}
else if(condition =='O')
{
discount = charges * 0.05;
upgrade = charges - discount;
cout<<"You may upgrade for a total cost of $"<<upgrade<<endl;
}
else
{
cout<<"There are upgrades avialble"<<endl;
}
cout<<"Do you want another one (y/n)?"<< endl;
cin>>keepgoing;
}while (keepgoing == 'Y' || keepgoing == 'y');
cout<<"Thank you for using this program. Goodbye."<<endl;
}
|