Question: Can you help me answer the following 3 C programming questions below, please? I will upvote. Problem Description: You have been hired by a movie
Can you help me answer the following 3 C programming questions below, please? I will upvote.
Problem Description:
You have been hired by a movie theatre to write an application that can compute the price of a ticket and any other charges to get the total price for the movie and print an itemized receipt. The price of a ticket is computed based on the following rules: The base price of a ticket is $14.00 Weekend tickets are increased by 20% of the base price, Evening tickets (17:00 or later) cost $3 more than matinee tickets, Blockbuster movies cost 10% more than the base price, Patrons 16 and younger get a 15% discount on the computed ticket price (not including food), Patrons 65 and older get a 10% discount on the computed ticket price, A snack pass is available for $15 which will allow you to get 3 medium-sized drinks and 2 medium-sized popcorn, VIP seating (includes a pillow!) is available on weekdays after 17:00 and all day on weekends. VIP seats can be purchased for an additional $5. The program will only ask if the patron wishes to purchase VIP seating if it is available for the show time selected. Taxes are calculated at 13% on the total of all purchases. The program will be pre-loaded with the schedule of the following movies.
code:
#define _CRT_SECURE_NO_WARNINGS #include
struct Timing { char time[50][50]; int isEvening[50]; int isWeekend[50]; int counter; };
char movies[10][50]; /ames of the movies struct Timing times[50]; int blockbuster[50];
void processData() { strcpy(movies[0], "The Gentleman"); strcpy(times[0].time[0], "Wed 15:30"); strcpy(times[0].time[1], "Thu 19:00"); strcpy(times[0].time[2], "Sat 13:00"); times[0].counter = 3; times[0].isEvening[0] = 0; times[0].isEvening[1] = 1; times[0].isEvening[2] = 0; times[0].isWeekend[0] = 0; times[0].isWeekend[1] = 0; times[0].isWeekend[2] = 1; blockbuster[0] = 0;
strcpy(movies[1], "The Invisible Man"); strcpy(times[1].time[0], "Tue 13:30"); strcpy(times[1].time[1], "Wed 19:00"); strcpy(times[1].time[2], "Sun 13:00"); times[1].counter = 3; times[1].isEvening[0] = 0; times[1].isEvening[1] = 1; times[1].isEvening[2] = 0; times[1].isWeekend[0] = 0; times[1].isWeekend[1] = 0; times[1].isWeekend[2] = 1; blockbuster[1] = 0;
strcpy(movies[2], "Sonic The Hedgehog"); strcpy(times[2].time[0], "Mon 16:30"); strcpy(times[2].time[1], "Fri 14:00"); times[2].counter = 2; times[2].isEvening[0] = 0; times[2].isEvening[1] = 0; times[2].isWeekend[0] = 0; times[2].isWeekend[1] = 0; blockbuster[2] = 1;
strcpy(movies[3], "Bad Boys for Life"); strcpy(times[3].time[0], "Mon 17:30"); strcpy(times[3].time[1], "Wed 10:00"); strcpy(times[3].time[2], "Sat 13:00"); strcpy(times[3].time[3], "Sun 15:00"); times[3].counter = 4; times[3].isEvening[0] = 1; times[3].isEvening[1] = 0; times[3].isEvening[2] = 0; times[3].isEvening[3] = 0; times[3].isWeekend[0] = 0; times[3].isWeekend[1] = 0; times[3].isWeekend[2] = 1; times[3].isWeekend[3] = 1; blockbuster[3] = 0; }
int main() { processData(); int age; printf("Enter your age: "); scanf("%d", &age); printf("Please select from the following movies: "); for (int i = 0; i = 65) { printf("age dicount: %.2f ", 0.10 * base_price); discount += 0.10 * base_price; } if (snack_pack) { printf("snack pass: %.2f ", 15.00); total += 15.00; } total -= discount; tax = 0.13 * total; printf("Tax: %.2f ", tax); printf(" TOTAL: %.2f ", total + tax);
return 0; }
Output:
:
Questions:
1. Which decision structures did you use in your program? Show an example of where you used two different decision structures and explain why you selected one over the alternatives in each of the two situations.
2. The program needed to remember the name and showtime of the movie the patron selected. Describe how you stored the name of the movie and the showtime so that they could be printed on the receipt.
3. The arithmetic in this program is done using floating point which is retaining fractional cents. Describe how floating point arithmetic might give a different answer from that using integer arithmetic to the nearest cent. If you were going to perform the arithmetic using integers, when would you need to convert floating point values to integers (in cents) to avoid the problem of fractional cents accumulating? You should list one or more points in the calculations when the values should be converted to cents.
Enter your age: 12 Please select from the following movies: 1. The Gentleman 2. The Invisible Man 3. Sonic The Hedgehog 4. Bad Boys for Life 3 Select one of the following show times: 1. Mon 16:30 2. Fri 14:00 2 Would you like to purchase our snack pack? (y) y **** Seneca Theatre *** Sonic The Hedgehog Fri 14:00 15.40 age dicount: 2.31 snack pass: 15.00 Tax: 3.65 TOTAL: 31.74 Enter your age: 12 Please select from the following movies: 1. The Gentleman 2. The Invisible Man 3. Sonic The Hedgehog 4. Bad Boys for Life 3 Select one of the following show times: 1. Mon 16:30 2. Fri 14:00 2 Would you like to purchase our snack pack? (y) y **** Seneca Theatre *** Sonic The Hedgehog Fri 14:00 15.40 age dicount: 2.31 snack pass: 15.00 Tax: 3.65 TOTAL: 31.74Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
