My code is supposed to be for an Arilines that allows the customer to purchase flights, calculate ho w much the customer owes, taking payment, and calculating change. However, I am totally lost why it is producing errors and what I need to add. Please help me get this code to work!! I'm not sure what to do. I feel I am missing a lot of code. :(((
Moreover, this is what my program must perform accurately:
1) Display a welcome message
2) Prompt the user to input his/her destination: Chicago, Miami, Portland (Using letters for input)
3) Prompt the user to input what time s/he wishes to travel (in army time, e.g., 800 for 8am or 1530 for 3:30pm)
4) Prompt the user to input what type of day (s) s/he is traveling: Weekday or Weekend (using letters to represent each input)
5)Report the price per ticket of the specified type
6) Prompt the user for the number of tickets to be purchased
7) Compute and display the total amount due (no sales tax needed)
8) Prompt the user to enter the amount s/he is paying (If the amount paid is less than the amount due, report that the amount paid is too little and the order has been cancelled, then exit; otherwise:
9) Display change and confirm the order has been placed.
Pricing info:
For Miami travel, flight prices are as follows:
For weekday travel: $150 during the daytime, $100 during the nighttime
For weekend travel: $180 during the daytime, $120 during the nighttime
Chicago flights cost half the price of Miami flights, and Portland flights cost twice as much as Miami flights. For ex: a Portland weekday flight during the nighttime is $200. A Chicago weekend flight during the daytime is $90.
Sample exceution:
Welcome to ___ Airlines
What is your destination? ([C]hicago, [M]iami, or [P]ortland): P
What time will you travel? (Enter time between 0-2359): 450
What type of day are you travelling: (week[E]nd or week[D]ay): E
Each ticket will cost: $240.00
How many tickets do you want?: 2
You owe: $480.00
How much will you pay: $100.00
That is too little! No tickets ordered.
(if its not too little -- it will look like: You will get ___ in change.
Your tickets have been ordered.)
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
1 // My name
2 // February
3 // This lab is our introduction to conditional statements
4
5 #include <iostream>
6 using namespace std;
7 int main ()
8
9 {
10
11 //variables
12 char op , cityCode, weekOrEnd, numoftickets, dayorWeek;
13 int time;
14 double userpay, ticketPrice;
15
16 //input
17
18 cout << "Enter destination city [C]hicago, [M]iami or [P]ortland : ";
19 cin >> cityCode;
20 cout << " Enter time you wish to travel (0000 - 2359) : ";
21 cin >> time;
22 cout << " Travelling week [D}ay or week[E]nd : ";
23 cin >> weekOrEnd;
24
25
26
27 switch (cityCode)
28
29 // Is it [C]hicago
30
31 {
32 case 'C':
33
34 switch (dayorWeek)
35
36
37
38 // Weekday
39 case 'W':
40 if (time >= 500 && time <= 1900)
41 ticketPrice = 75;
42 else
43 ticketPrice = 50;
44 break;
45
46
47 // Weekend
48 case 'E':
49 if (time > 500 && time <= 1900)
50 ticketPrice = 90;
51 else
52 ticketPrice = 60;
53 break;
54 }
55
56
57
58 // Is it [M]iami
59
60 {
61 case 'M':
62
63 switch (dayorWeek)
64
65
66 //Weekday
67 case 'W':
68 if (time >=500 && time <=1900)
69 ticketPrice = 150;
70 else
71 ticketPrice = 100;
72
73 break;
74
75 //Weekend
76 case 'E':
77 if (time >=500 && time <=1900)
78 ticketPrice = 180;
79 else
80 ticketPrice = 120;
81
82 break;
83 }
84
85
86
87
88 // Is it [P]ortland
89
90 {
91 case 'P':
92
93 switch (dayorWeek)
94
95 case 'P':
96
97 //Weekday
98 case 'W':
99 if (time >=500 && time <=1900)
100 ticketPrice = 300;
101 else
102 ticketPrice = 200;
103
104 break;
105
106
107 //Weekend
108 case 'E':
109 if (time >=500 && time <=1900)
110 ticketPrice = 360;
111 else
112 ticketPrice = 240;
113 break;
114 }
115
116
117
118 // Output
119
120 cout << " Enter the number of tickets you want : ";
121 cin >> numoftickets;
122 cout << " How much will will you pay: ";
123 cin >> userpay;
124 cout << " Your ticket's have been ordered! ";
125
126
127
128
129
130
131 return 0;
132 }
|