Having trouble with a program

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
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
 
#include <iostream>
using namespace 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;
            else if (hours <= 3 && day == 2)
                price = 25.00;
            break;
        case 2:
            cout << "250cc Mohawk, ";
            if (hours <= 3 && day == 1)
                price = 25.00;
            else if (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.
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
switch (vehicleClass)
    {
        case 1:
            cout << "50cc Moppette, ";
            if (hours <= 3 && day == 1)
                price = 15.00;
            else if (hours > 3 && day == 1)
              price = (hours - 3) * 2.5 + 15.;     
            else if (hours <= 3 && day == 2)
                price = 25.00;
            else if (hours > 3 && day == 2)
               price = (hours - 3) * 2.5 + 25.;     
            
            break;
        case 2:
            cout << "250cc Mohawk, ";
            if (hours <= 3 && day == 1)
                price = 25.00;
            else if (hours > 3 && day == 1)
              price = (hours - 3) * 2.5 + 25.;     
            else if (hours <= 3 && day == 2)
                price = 35.00;
            else if (hours > 3 && day == 2)
              price = (hours - 3) * 2.5 + 35.;     
            
            break;
        default:
                cout << "Unknown vehicle class";
    }
Last edited on
Ahh okay that makes sense thank you very much I appreciated.
Topic archived. No new replies allowed.