i am supposed to build a system which will produce output axactly d same as below:
car hours charges
1 1.5 2.00
2 4.0 2.50
3 24.0 10.00
TOTAL 29.5 14.50
user have to enter the value of hour and the counting is as follows:
within 3 hours, parkers are charged $2.00;
exceed 3 hours, parkers are charged $0.50 per hour and part thereof in excess of 3 hours;
maximum is 24 hours and are charged $10.00;
i wonder how to print and save the value of hour entered by user as i can't showed it as below:
Enter the hour: __
please help..
my code is as follow:
Code:
#include<stdio.h>
float enter_hours(float w);
float calculateCharges(float x,float y);
int main ()
{
float r,p,q;
printf("Car\tHours\tCharges\n");
for (int count=0;count<2;count++);
{
printf("\n%d\t%.1f\t%.2f",count,enter_hours(r),calculateCharges(p,q));
}
return (0);
}
float enter_hours(float w)
{
float x;
printf(" ");
scanf("%f",&x);
printf("%.1f",x);
}
float calculateCharges(float n,float x)
{
if (x<=3){
return 2.00;
}
if (x>3 && x<24){
return 2.00+0.50*n;
}
if (x==24){
return 10.00;
}
}