Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ Write a program that calculates and displays the bill for the Areo car renta

ID: 3580891 • Letter: C

Question

c++

Write a program that calculates and displays the bill for the Areo car rental company. The company rents three types of vehicles : compact, mid-size and full-size. Its rates vary, depending on the type of vehicle rented. The weekly rates are computed as follows :

Compact vehicle : $100.00 plus first 200 miles are free. Charges for over 200 miles are $0.20 per mile

Mid-size vehicle : $130.00 plus first 250 miles are free. Charges for over 250 miles are $0.15 per mile

Full-size vehicle : $150.00 plus : a. If it is a non-holiday week, the first 300 miles are free; charges for more than 300 miles is $0.25 per mile.

b. If it is a holiday week, the first 200 miles are free; charges for more than 200 miles is $0.30 per mile.

The program must prompt the user for vehicle code (type char) and the number of miles driven. A vehicle code of c or C means compact vehcile was rented, a vehicle code of m or 'M' means mid-size vehicle was rented and a vehicle code of f or 'F' means full-size vehicle was rented. Treat any other vehicle codes as an error and output the message "Invalid vehicle code entered". The program must output the vehicle type name (compact, mid-size or fullsize), miles driven and the amount due from the renter.

If a full-size vehicle is rented, the user must be prompted to determine if it was a holiday week.

Test cases

Vehicle Type        Mile used         Holiday week               Bill

     C                         190                                                $ 100.00

     c                         250                                                $ 110.00                   

     M                        200                                                $ 130.00

     m                        300                                                $ 137.50

                   

     F                         150                         Y                     $ 150.00

     f                        250                         Y                     $ 165.00   

     F                         150                        N                     $ 150.00

     f                         350                         N                    $ 162.50                  

              

     x    - Error message                                                                 

Explanation / Answer

#include<iostream>

using namespace std;


int main()
{
char ch,holiday_week;
int miles;
double bill;

cout<<"Vehicle code"<<endl;
cout<<"c or C : Compact Vehicle"<<endl;
cout<<"m or M : Mid-size Vehicle"<<endl;
cout<<"f or F : Full-size Vehicle"<<endl;
cout<<endl;
cout<<"Please enter vehicle code : "; //taking vehicle type
cin>>ch;
cout<<" Enter miles driven : "; //taking miles driven
cin>>miles;

switch(ch)
{
//for compact vehicle
case 'c':
case 'C':
if(miles > 200)
bill = 100.0 + ( 0.20 * (miles - 200));

else
bill = 100.0;

cout<<"Vehicle Type Miles Used Bill"<<endl;
cout<<"Compact Vehicle "<<miles<<" "<<"$"<<bill<<endl;

break;

//for midsize vhicle
case 'm':
case 'M':
if(miles > 250)
bill = 130.0 + ( 0.15 * (miles - 250));

else
bill = 130.0;

cout<<"Vehicle Type Miles Used Bill"<<endl;
cout<<"Mid-size Vehicle "<<miles<<" "<<"$"<<bill<<endl;

break;

//for full size vehicle
case 'f':
case 'F':
cout<<"Is it Holiday Week Y/N : ";
cin>>holiday_week;
//If it's holiday week
if(holiday_week == 'Y')
{
if(miles > 200)
bill = 150.0 + ( 0.30 * (miles - 200));

else
bill = 150.0;

}
//Not holiday week
else
{
if(miles > 300)
bill = 150.0 + ( 0.25 * (miles - 300));

else
bill = 150.0;

}
cout<<"Vehicle Type Miles Used Holiday Week Bill"<<endl;
cout<<"Full-size Vehicle "<<miles<<" "<<holiday_week<<" "<<"$"<<bill<<endl;
break;

default:
cout<<"Invalid Vehicle type"<<endl;
}
return 0;
}

Please refer below output

Vehicle code
c or C : Compact Vehicle
m or M : Mid-size Vehicle
f or F : Full-size Vehicle

Please enter vehicle code : f

Enter miles driven : 350
Is it Holiday Week Y/N : N
Vehicle Type Miles Used Holiday Week Bill
Full-size Vehicle 350 N $162.5

Process returned 0 (0x0) execution time : 16.600 s
Press any key to continue.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote