Question: 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

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

answer those above question based on the following c code please:

#include  #include  struct Timing { char time[50][50]; int isEvening[50]; int isWeekend[50]; int counter; }; char movies[10][50]; //names 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 <= 3; i++) { printf("%d. %s ", i + 1, movies[i]); } char choice[10]; scanf("%s", choice); printf("Select one of the following show times: "); int n = (choice[0] - '1'); for (int i = 0; i < times[n].counter; i++) { printf("%d. %s ", i + 1, times[n].time[i]); } char time_choice[10]; scanf("%s", time_choice); int snack_pack; char yn[10]; while (1) { printf("Would you like to purchase our snack pack?(y/n) "); scanf("%s", yn); if (yn[0] == 'y') { snack_pack = 1; break; } else if (yn[0] == 'n') { snack_pack = 0; break; } else { printf(" invalid choice please provide y for yes or n for no "); } } printf(" ************************ Seneca Theatre ******************************* "); float base_price = 14.0, discount = 0, total = base_price, tax; if (blockbuster[n]) { total += 0.1 * base_price; base_price *= 1.1; } if (times[n].isEvening[time_choice[0] - '1']) { total += 3; base_price += 3; } if (times[n].isWeekend[time_choice[0] - '1']) { total += 0.2 * base_price; base_price *= 1.2; } printf("%s %s %.2f ", movies[n], times[n].time[time_choice[0] - '1'], base_price); if (age <= 16) { printf("age dicount: %.2f ", 0.15 * base_price); discount += 0.15 * base_price; } if (age >= 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; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!