The short-term, 0-24 hours, parking fee, F, at an international airport is given by the following formula:  5, if 0 # h # 3 F563int(h11), if3,h#9  6 0 , i f 9 , h # 2 4 where int(h + 1) is the integer value of h + 1. For example, int(3.2) = 3, int(4.8) = 4. Write a program that prompts the user to enter the num- ber of hours a car is parked at the airport and outputs the parking fee.

Respuesta :

The following code will program that prompts the user to enter the num- ber of hours a car is parked at the airport and outputs the parking fee.

Explanation:

Code:

#include<iostream>

using namespace std;

int main()

{

float hours;

cout <<"Enter number of hours a car parked at the airport: "; // prompt the user to enter hours.

cin >> hours ; // strong the hours

if (hours > = 0 && hours < =3 ) // if 0 < = h < = 3

cout << "Parking fee: 5"; //printing parking fee is 5.

else if (hours > 3 && hours < = 9)//if 3 < h < = 9

cout<<"Parking fee: "<<6*int(hours);//converting float value to int the multiplying with 6 then printing fee.

else//if 9 < h < = 24

cout<< "Parking fee: 60";// printing parking fee 60.

return 0;

}

ACCESS MORE