C PROGRAM... You are a new programmer for Disney and are helping out for their P
ID: 3666678 • Letter: C
Question
C PROGRAM... You are a new programmer for Disney and are helping out for their Pass System at the Magic Kingdom. Currently, there is a test system in place to give out fast passes at the following attractions: 1. Space Mountain 2. The Haunted Mansion 3. Pirates of the Caribbean You need to create a program that will allow users to pick out fast passes for these attractions for the following test days: Friday and Sunday. The program needs to allow the user to pick in half hour increments from 6:00-9:00pm. A user can only pick out 3 fast passes on Friday and Sunday, You also need to notify the user when there is no more fast passes available, there are some problems that have also inhibited guest from getting fast passes: 1. The Haunted Mansion does not give fast passes from 7:45pm -9:00pm on Friday’s because of fireworks 2. The pirates of the Caribbean will be down for refurbishment from 6:00-7:30pm on Sundays 3. Space Mountain will not be available for fast passes because of a character meet and greet on Friday and Saturdays from 7:00-8:00pm You will need to develop a program in C based on this scenario, use all of the concepts you have learned so far in order to complete this task including if/else and switch statements.
Explanation / Answer
#include <stdio.h>
int main()
{
int choice;
double t;
int d;
int allow;
int fast_pass = 3;
while(1)
{
allow = 1;
printf(" Select the attraction for the fast pass ");
printf("1. Space Mountain 2. The Haunted Mansion 3. Pirates of the Caribbean 4. Exit ");
printf("Enter your choice::");
scanf("%d",&choice);
if(choice == 4)
break;
printf("Enter time (in pm)::");
scanf("%lf",&t);
if(t!=6&&t!=6.30&&t!=7&&t!=7.30&&t!=8&&t!=8.30&&t!=9)
{
printf("The user is allowed only to pick in half hour increments from 6:00-9:00pm ");
continue;
}
printf("Friday(press 1)/Sunday(press 2)::");
scanf("%d",&d);
if(d!=1&&d!=2)
{
printf("Enter 1 or 2 only ");
continue;
}
switch( choice )
{
case 2:
if(t>=7.45&&t<=9 && d==1)
{
printf("The Haunted Mansion does not give fast passes from 7:45pm -9:00pm on Friday’s because of fireworks ");
allow = 0;
}
break;
case 3:
if(t>=6&&t<=7.30 && d==2)
{
printf("The pirates of the Caribbean will be down for refurbishment from 6:00-7:30pm on Sundays ");
allow = 0;
}
break;
case 1:
if(t>=7&&t<=8 && ( d==1 || d==2))
{
printf("Space Mountain will not be available for fast passes because of a character meet and greet on Friday and Saturdays from 7:00-8:00pm ");
allow = 0;
}
break;
}
if(allow)
{
if(fast_pass==0)
printf("A user can only pick out 3 fast passes on Friday and Sunday ");
else
{
printf("You are granted a fast pass ");
fast_pass--;
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.