Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please, help me to program admission price by using c programming language AGE P

ID: 3911312 • Letter: P

Question

Please, help me to program admission price by using c programming language



AGE PRICE 14 and under $5.00 15 to 64 $9.00 65 and over $7.50 In addition, Hopper's museum offers a 1-dollar-off coupon that the patron may have. This program will first get the current date from the system, and then query the patron fo coupon. Based on this information, the program will then calculate the patron's age and admission price and display it for the user. (Note that this means your program will calculate the user's age. r his/her date of birth. The program will then ask if s/he has a discount

Explanation / Answer

The code is given below

#include<time.h>
#include<stdio.h>
int main()
{
time_t rawtime;
time ( &rawtime );
struct tm *timeinfo = localtime ( &rawtime );
int d,m,y;
printf("Enter your Date of Birth mm dd yyyy: ");
scanf("%d %d %d",&m,&d,&y);
int month[] = { 31, 28, 31, 30, 31, 30, 31,
31, 30, 31, 30, 31 };
timeinfo->tm_year+=1900;
timeinfo->tm_mon++;
if (d > timeinfo->tm_mday) {
timeinfo->tm_mday +=month[m - 1];
timeinfo->tm_mon--;
}

if (m > timeinfo->tm_mon) {
timeinfo->tm_year--;
timeinfo->tm_mon+=12;
}
int age=timeinfo->tm_year-y;
char c;
printf("Do you have a discount coupon (y/n)? ");
scanf(" %c",&c);
double cost;
if(age<=14)cost=5;
else if(age<=64)cost=9;
else cost=7.5;
if(c=='y')cost--;
printf("Your admission fee is $%.2f, enjoy your visit! ",cost);
}

Do give a thumbs up