Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am writing a code that: A parking garage charges $2 for minimum fee to park up

ID: 3529169 • Letter: I

Question

I am writing a code that: A parking garage charges $2 for minimum fee to park up to 3 hours and then a $.50 per hour charge after the 3rd hour. The maximum charge for any 24 hour parking is $10. Assume no car parks longer than 24 hrs, write a program that calculates and prints the parking charge for each of 3 customer. Result should be printed in tabular format. Hint: use function called calculateCHarge to determine charge for each customer. I have the following code already but I am encountering errors. please help. #include #include float calculateCharges(float); int main(void) { float hours1, hours2, hours3, charge, charge1, charge2, charge3,charges,totalhours, totalCharges, hoursStayed; printf("Enter the hours parked for 3 cars: "); scanf_s("%f %f %f ", &hours1, &hours2, &hours3); charge = calculateCharges; totalhours = hours1 + hours2 + hours3; totalCharges = (charge1 + charge2 + charge3); printf(" "); printf("Car Hours Charge "); printf("1 %f %f ", hours1, charge1); printf("2 %f %f ", hours2, charge2); printf("3 %f %f ", hours3, charge3); printf("Total %f %f ", totalhours, totalCharges); return 0; } float calculateCharges(float hoursStayed){ float charge, MIN_FEE, MAX_FEE; charge = MIN_FEE; if( hoursStayed >= 24.0 ) { return MAX_FEE; } if(hoursStayed > 3.0) { charge += 0.5F * (hoursStayed-3.0F) ; } return charge; }

Explanation / Answer

PERFECT WORKING SOLUTION!!!


PLEASE RATE IT FIRST!!!



#include<stdio.h>
#include<stdlib.h>

float calculateCharges(float);
int main(void) {
float hours1, hours2, hours3, charge, charge1, charge2, charge3, charges,totalhours, totalCharges;

printf("Enter the hours parked for 3 cars: ");
scanf_s("%f %f %f ", &hours1, &hours2, &hours3);
charge1 = calculateCharges(hours1);
charge2 = calculateCharges(hours2);
charge3 = calculateCharges(hours3);
totalhours = hours1 + hours2 + hours3;
totalCharges = charge1 + charge2 + charge3;

printf(" ");
printf("Car Hours Charge ");
printf("1 %f %f ", hours1, charge1);
printf("2 %f %f ", hours2, charge2);
printf("3 %f %f ", hours3, charge3);

printf("Total %f %f ", totalhours, totalCharges);

return 0;
}

float calculateCharges(float hoursStayed){
float charge, MIN_FEE, MAX_FEE;
MIN_FEE = 2;
MAX_FEE = 10;
if (hoursStayed <=3)
charge = MIN_FEE;
if (hoursStayed >3
charge = MIN_FEE + 0.5*(hoursStayed-3)
if (charge>10)
charge = 10;
return charge;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote