Answer to Question #188384 in C for Ashly

Question #188384

Parking lot charges rs.30.00as a minimum fee to park a vehicle for upto 3hours.an additional charge of re 5.00 per hour will be added if exceed three hours.for 24hours the parking fee are 80.00 write a program to define an array and read the vehicle registration bumber,and hiurs parked for each customer and calculate the parking for n customer and display the output



1
Expert's answer
2021-05-03T03:32:08-0400
#include <stdio.h>
#include <string>



#define NO_OF_VEHICLES	100
main(void)
{
	int ParkingHours[NO_OF_VEHICLES], ParkingFee[NO_OF_VEHICLES],Flag=1, Diff=0;
	int n=0,r,Sum=0;
	char VehicleNum[NO_OF_VEHICLES][10];
	while(Flag)
	{
		printf("\nEnter Vehicle No.: "); scanf("%s",&VehicleNum[n]);
		printf("\nEnter the Parking Hours: "); scanf("%d",&ParkingHours[n]);
		if(ParkingHours[n]<=3)	ParkingFee[n] = 30;
		if(ParkingHours[n]>3 && ParkingHours[n]<=24) 
		{
			Diff = ParkingHours[n]-3;
			ParkingFee[n] = 30 + 	Diff*5;
		}
		if(ParkingHours[n]>3 && ParkingHours[n]<=24) 
		{
			Diff = ParkingHours[n]-3;
			ParkingFee[n] = 30 + 	Diff*5;
		}
		if(ParkingHours[n]>80)	ParkingFee[n] = 80;	
		Sum = Sum + ParkingFee[n];
		printf("\nParking Fee = %d",ParkingFee[n]);
		n=n+1;
		printf("\n\nPress 1 to continue Or 0 to QUIT: "); scanf("%d",&Flag);
	}
	printf("\nVehicle No.   Parking Hours    Parking Fee");
	for(r=0;r<n;r++)
	{
		printf("\n%s\t\t\t%d\t%d",VehicleNum[r],ParkingHours[r],ParkingFee[r]);
	}
	printf("\nTota Parking Fee Collected = %d",Sum);
	return(0);
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS