Answer to Question #245239 in C++ for Junior

Question #245239

This test requires you to implement the task given below as a C++ program.

This program is for a car rental agency. Your program will have to compute the total cost of a rental. This agency has three types of cars, and the rates per day for rental are as follows:

Compact Car - Rental Price =$40.00

Mid Size Car-Rental Price=$55.00

Luxury Car-Rental Price=$70.00

All car rentals require a purchase of comprehensive insurance costing $15.00 per day and an initial one time bond payment of $100.00. Create an application that will ask for the type of car and the duration of car rental to calculate the cost of car rental.

You have to apply all the programming constructs that you have learned so far, as needed, to complete this exercise. (decisions, loops, input validation)

Sample Run 1:

Enter type of car: 2

Enter days of rental: 5

Cost of rental for 5 days is $ 450.00


1
Expert's answer
2021-10-01T07:45:43-0400
#include <iostream>
#include <string>


using namespace std;




int main() {
	cout << "Enter type of car: " << endl;
	int t, d;
	cin >> t;
	cout << "Enter days of rental: " << endl;
	cin >> d;
	switch (t)	{
	case 1:	
		cout << "Cost of rental for " << d << "days is $ " << (55 * d)+100;
		break;
	case 2:
		cout << "Cost of rental for " << d << "days is $ " << (70 * d)+100;
		break;
	case 3:
		cout << "Cost of rental for " << d << "days is $ " << (85 * d)+100;
		break;
	default:
		break;
	}


	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS