1. Write a program that calculates the cost of washing an automobile. The cost o
ID: 3552912 • Letter: 1
Question
1. Write a program that calculates the cost of washing an automobile. The cost of washing will depend upon what actions the owner requests to be performed. Certain operations depend on the number of doors of the vehicle. In addition to the service costs, be sure to add 8.5% sales tax to the total cost of the service fees. Use the table below to calculate the service fees.
Service Fees
Operation
Cost
Wash
$3.00 for 2-door cars
$5.00 for 4-door cars
$10.00 for larger vehicles
Wax
$7.00 for 2-door cars
$10.00 for 4-door cars
$20.00 for larger vehicles
Tire Cleaning
$13.00 for 2-door cars
$15.00 for 4-door cars
$20.00 for larger vehicles
A sample program dialogue is shown below to help guide your efforts:
Let me wash you vehicle:
How many doors? 4
Wash: Y
Wax: N
Tires: N
Base on your vehicle specs, your service fee including an 8.5% sales tax is $5.43.
Your program should properly request input from the user and use constants to represent certain fixed values. (Points : 20)
Service Fees
Operation
Cost
Wash
$3.00 for 2-door cars
$5.00 for 4-door cars
$10.00 for larger vehicles
Wax
$7.00 for 2-door cars
$10.00 for 4-door cars
$20.00 for larger vehicles
Tire Cleaning
$13.00 for 2-door cars
$15.00 for 4-door cars
$20.00 for larger vehicles
Explanation / Answer
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float Wash[3]={3,5,10};
float Wax[3]={7,10,20};
float Tires[3]={13,15,20};
int doors;
float costv=0;
char c;
cout << "Let me wash you vehicle:" << endl;
cout << "How many doors?" << endl;
cin>>doors;
cout << "Wash:" << endl;
cin>>c;
if(c=='Y'){costv+=Wash[(int)ceil(doors/2)-1];}
cout << "Wax:" << endl;
cin>>c;
if(c=='Y'){costv+=Wax[(int)ceil(doors/2)-1];}
cout << "Tires:" << endl;
cin>>c;
if(c=='Y'){costv+=Tires[(int)ceil(doors/2)-1];}
cout << "Base on your svehicle specs, your service fee including an 8.5% sales tax is $"<<floorf((costv*1.085) * 100 + 0.5) / 100<<endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.