Hello there again, I'm having a slight problem I'm trying to create a program that calculates Moped rentals by hours and what type of day.For example a moped rental on a weekday, for the first three hours is $15.00. After every hour after the third hour the price increases by $2.50. This is the part I'm having trouble with, increasing the price after the third hour. This is my code so far
#include <iostream>
usingnamespace std;
int main()
{
cout << "****** Welcome to my Moped Rental Shop ******\n\n";
int vehicleClass;
int day;
double hours;
double total;
double price;
cout << "Which type of moped (1 -- 50cc Mopette, 2 -- 250cc Mohawk)?";
cin >> vehicleClass;
cout << "What day (1 -- weekday, 2 -- weekend)?";
cin >> day;
cout << "How many hours (enter a double)?";
cin >> hours;
switch (vehicleClass)
{
case 1:
cout << "50cc Moppette, ";
if (hours <= 3 && day == 1)
price = 15.00;
elseif (hours <= 3 && day == 2)
price = 25.00;
break;
case 2:
cout << "250cc Mohawk, ";
if (hours <= 3 && day == 1)
price = 25.00;
elseif (hours <= 3 && day == 2)
price = 35.00;
break;
default:
cout << "Unknown vehicle class";
}
switch (day)
{
case 1:
cout << "weekday, ";
break;
case 2:
cout << "weekend, ";
break;
default:
cout << "Unknown day";
}
cout << hours << " hours" << endl;
//magic formula
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "==> Your rental charge would be $" << price << endl;
cout << "****** Thank you for shopping with us! ******" << endl;
system("pause");
return 0;
}
I am able to make the program output $15.00 for the first three hours but stuck if any other number were inputted greater than 3.0. Thank you any help would be appreciated.