In: Computer Science
Use CPP
1) Parking charge application: A parking garage charges a $20.00 minimum fee to park for up to 3 hours. The garage charges an additional $5.00 per hour for hour or part thereof in excess of 3 hours. The maximum charge for any given 24-hour period is $50.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and prints the parking charge for each of 3 customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program should save the result in a array of Customer. The class customer is the following:
class customer{ string plate; float hour; float fee; }
Your program should use the function calculateCharges to determine the fee for each customer. You should print the result for the 3 customers in the following format:
Plate Hours Charge
132AAC 1.5 20.00
236URT 4.0 25.00
390ROP 24.0 50.00
TOTAL 29.5 95.00
In doing this question make sure to keep the array of customer as global variable.
Please send me the screenshot of output too.
Thanks
Program Parking charge application.
This program program use the function calculateCharges to determine the fee for each customer.
#include <iostream>
using namespace std;
int a[3];
// create a class customer
class customer
{
string plate;
float hour;
float fee;
int charges;
public:
void display()
{
int i,ch,sum=0;
for(i=0;i<=2;i++)
{
cout<<"Enter Plate";
cin>>plate;
cout<<"Enter hour";
cin>>hour;
cout<<plate<<"\t";
cout<<hour<<"\t";
// Invoking function calculateCharges
ch=calculateCharges(hour);
cout<<ch<<endl;
a[i]=ch;
sum=sum+ch;
}
cout<<sum;
}
// definition of function calculateCharges
int calculateCharges(float h)
{
if(h<=3)
charges=20;
else
charges=20+(h-3)*5;
if(charges>50)
charges=50;
return charges;
}
};
// main program
int main() {
customer obj; // object creation for class customer
obj.display();
}