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