The sign on the attendant’s booth at the XYZ parking lot is XYZ VISITOR PARKING
ID: 3629661 • Letter: T
Question
The sign on the attendant’s booth at the XYZ parking lot is
XYZ VISITOR PARKING
Cars:
First 2 hours Free
Next 3 hours 0.50/hour
Next 10 hours .25/hour
Trucks:
First 1 hour Free
Next 2 hours 1.00/hours
Next 12 hours 0.75/hour
Senior Citizens: Free of charge
Write a program that will accept as input a one-character designator (C, T or S)
Followed by two military numbers in range of 0600-2200 (6:00 A.M to 10:00 P.M). The program should
Then compute the appropriate charge and the round up time that car was parked.
The output should be printed for each vehicle , arrival time, departure time and cost. Your program should also provide a summer at the end of each day indicating total cars, trucks, and senior , time and fees. Your program should have loop which ends with ^Z.
Explanation / Answer
please rate - thanks
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
int main()
{int i;
char type,ch;
int enter,exit,cars=0,trucks=0,senior=0,cat1,cat2,cat3,hours;
double time=0,fees=0,p1=0,p2,p3,totfees=0;
do
{
printf("Enter category (C)ar,(T)ruck, (S)enior : ");
scanf("%c",&type);
type=toupper(type);
if(type!='C'&&type!='S'&&type!='T')
printf("invalidcategory ");
}while(type!='C'&&type!='S'&&type!='T');
while(1)
{do
{printf("What time did the vehicle enter 0600-2200? ");
scanf("%d",&enter);
if(enter<600||enter>=2200)
printf("Sorry impossible-the lot was closed!! ");
}while(enter<600||enter>=2200);
do
{printf("What time did the vehicle exit 0600-2200? ");
scanf("%d",&exit);
if(exit<600||exit>2200)
printf("Sorry impossible-the lot wasclosed!! ");
}while(exit<600||exit>2200);
hours=((exit-enter)+59)/100;
while ((ch = getchar()) != ' ' )
fees=0;
switch(type)
{case 'C':cat1=2;
cat2=3;
cat3=10;
p2=.5;
p3=.25;
cars++;
break;
case 'T':cat1=1;
cat2=2;
cat3=12;
p2=1;
p3=.75;
trucks++;
break;
case 'S':
senior++;
p2=0;
}
time+=hours;
if(p2!=0)
{hours-=cat1;
if(hours<0)
hours=0;
printf("hours %d ",hours);
if(hours>cat2)
{fees=cat2*p2+fees;
hours-=cat2;
}
else
{fees=hours*p2+fees;
hours=0;
}
if(hours>cat3)
fees=cat3*p3+fees;
else
fees=hours*p3+fees;
}
totfees+=fees;
printf("Vehicle type: %c ",type);
printf("Arrival Time: %d ",enter);
printf("Departure Time: %d ",exit);
printf("cost: $%7.2f ",fees);
do
{
printf("Enter category (C)ar,(T)ruck, (S)enior (Ctrl Z when done):");
if(scanf("%c",&type)!=1)
{printf(" Daily Summary: ");
printf("Total Cars: %d ",cars);
printf("Total Trucks: %d ",trucks);
printf("Total Seniors: %d ",senior);
printf("Total Time: %d hours ",time);
printf("Total Fees: $%7.2f ",totfees);
getch();
return 0;
}
type=toupper(type);
if(type!='C'&&type!='S'&&type!='T')
printf("invalid category ");
}while(type!='C'&&type!='S'&&type!='T');
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.