Switch Madness!!

So...in my haste I started working on the wrong assignment and neglected the one due in <100 minutes.

I am trying to write a program that allows a user to select a ticket to a theme park, and then gives a discount based on their selection and number of days, and them prints out a nice ticket below. I do not have the capability to solve all these issues in Xcode, as I do not even know what they mean.

Please help me to get this thing to compile.

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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <iostream>
using namespace std;


int main()
{
    int day;
    int type;
    int brand;
    double total;
    double totdis;
    double bc;
    const double opodp = 102.00;
    const double php = 110.00;
    const double opodwwp = 117.00;
    const double phwwp = 125.00;
    const double ap = 749.00;
    char name;
    
    cout << "Programmed by Mr. X" << endl << endl;
    cout << " " << endl;
    cout << "Amusement Park" << endl;
    cout << "Ticket Menu" << endl;
    cout << "     1. One Park One Day" << endl;
    cout << "     2. Park Hopper Pass" << endl;
    cout << "     3. One Park One Day with Water Park Pass" << endl;
    cout << "     4. Park Hopper Pass with Water Park Pass" << endl;
    cout << "     5. Annual Pass" << endl;
    cout << " " << endl;
    cout << "Which pass are you purchasing: " << endl;
    cin >> type;
    if (type < 0 || type >5)
    {cout << "Invalid Selection";
    }
    else
    {
    cout << "How many days would you like on the ticket: " << endl;
    cin >> day;
        if (day <1)
            cout << "Invalid Selection" << endl;
        else if (day == 1)
            totdis = 1;
        else if (day <=3)
            totdis = 0.9;
        else if (day <=6)
            totdis = 0.8;
        else if (day > 6)
            totdis = 0.7;
            }
    
    switch (type)
    {
            case 1:
                total = (opodp * day) * totdis;
                break;
            case 2:
                total = (php * day) * totdis;
                break;
            case 3:
                total = (opodwwp * day) * totdis;
                break;
            case 4:
                total = (phwwp * day) * totdis;
                break;
            case 5:
                total = (ap * day) * totdis;
                break;
    }

    cout << "******************************************************" << endl;
    cout << "* Ticket Receipt" << endl;
    cout << "******************************************************" << endl;
    cout << "* Ticket Type :" << brand << endl;

    switch (type)
    {
        case 1:
            brand = (One Park One Day Pass);  [ERROR]
            break;
        case 2:
            brand = (Park Hopper Pass); [ERROR]
            break;
        case 3:
            brand = (One Park One Day with Water Park); [ERROR]
            break;
        case 4:
            brand = (Park Hopper with Water Park); [ERROR]
            break;
        case 5:
            brand = (Annual Pass); [ERROR]
            break;
    }
    
    cout << "* Base Cost: $" << bc << endl;
        if (type = 1) [ERROR]
        {bc = opodp}
        else if (type = 2)
        {bc = php}
        else if (type = 3)
        {bc = opodwwp}
        else if (type = 4)
        {bc = phwwp}
        else if (type = 5)
        {bc = ap}
    
    cout << "* Number of Days: " << day << endl;
    cout << "Purchase Price: $" << total << endl;
        if (total <= 749)
        {total = total)
            else if (total >749)
            {total = ap)
                
    cout << "******************************************************" << endl;
    return 0;

    }
Last edited on
 
type int choice; [ERROR]

type isn't a valid variable type.
Last edited on
Made even more corrections, but I am getting an [Expected ')'] with an [Unknown type name 'One'] on the ticket type.

All I want it to do it just type out the name of the ticket.
Last edited on
I can help you with some compiler errors within if else if statement and the switch (type) statement.

For the else if statement,
else if (day >=2 || <=3) [ERROR]

you need to completely type it out. So,
else if (day >= 2 || day <=3)

That would get rid of your compiler error on both lines 42 and 44.

switch (type)
case 1: // You have to use case 1. I removed the double quotes around the 1 because with the quotes, you are making it a string, and not an int.

This would apply to lines, 52, 55, 58, 61, 64.


What do you mean on line seventeen with type choice?
Topic archived. No new replies allowed.