Question

C programming Construct a console program to simulate Zoo ticketing system. The system is used for dispensing tickets to customers. In order to buy tickets, the customer need to enter the following information: a) Number of ticket they want to buy. Everybody must have a ticket to enter. b) Only up to 5 tickets may be purchased for every transaction or customer. c) Type of ticket either for adult, children (aged 5 12 years old) or toddler (aged 2-5 years old). Babies (aged 2 and below) are free of charge, but still need tickets to enter. d) Customers may also choose to include buggy ride in their ticket. Charges for the ride apply to everyone except babies. e) The system also offers food coupon for lunch inside the zoo cafeteria at a very reasonable price Requirements: Your system should be able: a) To display the ticketing details as shown in Figure-I for customer information; ticketing details as shown in Figure-1 for customer information; allow up to maximum 3 categories of tickets for each customer/transaction. The number of tickets is unlimited; o) To display the details of tickets purchased by each customer and the calculated total price in a single receipt; d) To operate continuously for customer to purchase ticket until user choose to exit from the system e) To display all the transaction details at any time when it is needed; and f) To save all the transactions to a file (.txt or dat) as illustrated in Figure system is exited. -2 before the You should show program modularity in your solution using functions and your projedt MUST apply the following mechanisms to store and organize the data for your project: a) Array/ Pointer b) Basic Data Structure c) File Operations Zoo Ticketing Details Zoo Ticketing Details Ticket(RM) Buggy Ride 00 3.00 1.50 Free Category Lunch Coupon(RM) a)Adult b)Childrern c)Toddler d)Babies 17.50 12.00 7.50 Free Figure-1: The Ticketing Details RM 5.50/person RM5

Category FrequencyBuggy Ride Lunch Coupon Amount(RM) Receipt No. Adult Children 56.00 35.50 001 51.00 14.50 002 Adult Adult Children Babies 79.00 41.00 0.00 003 Figure-2: Example of transaction details of all the ticket purchased

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

int main()
{
FILE * fp;//to write to a file
int n=1,a[4],b[4],l[4];
double cost[4];
char c[4][10]={"Adults","Children","Toddlers","Babies"};
char x=' ',z;
fp = fopen("C:\\Users\\darsh\\Desktop\\csis.txt","w");//change according to path you require

while(1)
{
for(int i=0;i<4;i++)
{
printf("For %s\n",c[i]);
printf("Enter how many number of tickets are required ");
scanf("%d",&a[i]);
printf("Enter no of buggy rides ");
scanf("%d",&b[i]);
printf("Enter number of lunch coupons required ");
scanf("%d",&l[i]);
}

cost[0]=a[0]*17.5+b[0]*5+l[0]*5.5;
cost[1]=a[1]*12+b[1]*3+l[1]*5.5;
cost[2]=a[2]*7.5+b[2]*1.5+l[2]*5.5;
cost[3]=a[3]*0+b[3]*0+l[3]*5.5;
printf("\n\n");
printf("Recepient no Category Frequency Buggy ride Lunch coupon Amount\n");
fprintf(fp,"Recepient no Category Frequency Buggy ride Lunch coupon Amount\n");//writing into file
printf("%12d",n);
fprintf(fp,"%12d",n);
for(int i=0;i<4;i++)
{
if(i!=0)
printf("%12c",x);
if(a[i]>0)
{
printf("%12s",c[i]);
printf("%13d",a[i]);
printf("%14d",b[i]);
printf("%12d",l[i]);
printf("%16lf",cost[i]);

fprintf(fp,"%12s",c[i]);
fprintf(fp,"%13d",a[i]);
fprintf(fp,"%14d",b[i]);//writing into file
fprintf(fp,"%12d",l[i]);
fprintf(fp,"%16lf",cost[i]);
}
printf("\n");
fprintf(fp,"\n");
}
printf("\n");
fprintf(fp,"\n");

printf("To exit press e else press anything else ");
getchar();
scanf("%c",&z);
if(z=='e')
break;
}

fclose (fp);
}

output from console

Enter how many number of tickets are required 1 Enter no of buggy rides 1 Enter number of lunch coupons required 1 For Children Enter how many number of tickets are required 1 Eriler no of buggy rides 1 Fnter number of lunch coupons required 1 For Toddlers Enter how many number of tickets are required 1 Enter no of buggy rides 1 Fnter number of lunch coupons required 1 Tor Babies Enter how many number of tickets are required Enter no of buggy rides Enter number of lunch coupons required Recepient no Category Frequency gey ride unch couponAmount Adults Children Toddler 20.500000 14.500000 To exit press e else press anything else 2 For Adults nter how many number of tickets are required Enter no of buggy rides 2 Enter number of lunch coupons required 2 For Children tnter how many number of tickets are required 2 Enter no of buggy rides 2 Enter number of lunch coupons required 1 For Toddlers Enter how many number of tickets are required 1 Enter no of buggy rides 1 Enter number of lunch coupons required 1 For Rabies Enter how many Enter no of buggy rides Enter number of lunch coupons required number of ticket s are required 8 Recepient no Category Frequency Buggy ride Lunch coupon Amount Adults 56.800800 0:47 O Type here to search FNIG 09-12-201

output written into text file( Note that I am uploading screenshot because I'm unable add text file)

Add a comment
Know the answer?
Add Answer to:
C programming Construct a console program to simulate Zoo ticketing system. The system is used for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT