1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
victus00 [196]
3 years ago
5

A Water Amusement Park parking lot charges $24.00 minimum fee to park for up to 8 hours. The meter charges an additional $3.25 p

er hour for each hour in excess of eight hours. In addition, an extra $10 is charged if it's a recreational vehicle (RV). The maximum charge for any 24-hour period, for any type of vehicle is $70 .
Write a program that calculates and prints the customer information and parking charges to a text file (charge-report.txt) for each of five customers who parked their cars using the Water Amusement Park parking lot . The program should use the following functions:


getNameAndHoursParked(): a void function that asks for the employee’s full name and Number of Hours Parked. Use pass-by-reference to send these two items to main(). (10 points)

isVehicleNotAnRV: a value returning function that asks if vehicle is not a Recreational Vehicle and returns true or false. (5 points)

getFinalCharge(): a value returning function that calculates and returns the final charge for a customer to main(). (15 points)

The main() function should print the customer's full name, an indication of whether vehicle is a Recreational Vehicle, hours and charge for each customer to an output file (charge-report.txt) . (10 points)

in c++
Engineering
2 answers:
Naily [24]3 years ago
5 0

Answer:

See explaination for the program code

Explanation:

Program code below;

#include<iostream>

#include<fstream>

#include<iomanip>

using namespace std;

//function to return name and hours

void getNameAndHoursParked(string &name, int &hours)

{

cout<<"Enter the employee's full name: ";

getline(cin, name);

cout<<"Enter Number of Hours Parked: ";

cin>>hours;

}

//function to check if vehicle is not a Recreational Vehicle

bool isVehicleNotAnRV()

{

string rv;

cout<<"Is the vehicle is not a Recreational Vehicle: (Y/N)";

cin>>rv;

cin.ignore();

if(rv=="Y" || rv=="y") return true;

return false;

}

//function to calculates the parking charges

float getFinalCharge(int hours, bool rv)

{

float charge;

if(hours<=8)

charge = 24;

else

charge = 24 + (hours-8)*3.25;

if(rv) charge += 10;

if(hours<=24 && charge>70) charge = 70;

return charge;

}

//main function

int main()

{

//variable declaration

string name;

int hours;

ofstream ofs;

//open the file

ofs.open("charge-report.txt");

ofs<<left<<setw(15)<<"Full Name"<<setw(15)<<"Parking-Hours";

ofs<<setw(10)<<"Is-RV"<<"Charge"<<endl;

for(int i=0; i<5; i++)

{

//get name and parking hours

getNameAndHoursParked(name, hours);

//check if vehicle is not a Recreational Vehicle

bool rv =isVehicleNotAnRV();

//calculates the parking charges

float charge = getFinalCharge(hours, rv);

ofs<<left<<setw(20)<<name<<setw(10)<<hours;

ofs<<setw(10)<<boolalpha<<rv<<"$"<<charge<<endl;

}

//close the file

ofs.close();

return 0;

}

Klio2033 [76]3 years ago
4 0

Answer:

  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. void getNameAndHoursParked(string &name, int &hour){
  5.    cout<<"Enter employee name: ";
  6.    cin>>name;
  7.    cout<<"Enter parking hours: ";
  8.    cin>>hour;
  9. }
  10. bool isVehicleNotAnRV(){
  11.    int response;
  12.    cout<<"Is vehicle an RV: (1) Yes  (2) No: ";
  13.    cin>>response;
  14.    
  15.    if(response == 1){
  16.        return true;
  17.    }else{
  18.        return false;
  19.    }
  20. }
  21. double getFinalCharge(int hour, bool rv){
  22.    double charge;
  23.    
  24.    if(hour <=8){
  25.        charge = 24;
  26.    }
  27.    else{
  28.        hour = hour - 8;
  29.        charge = 24 + hour * 3.25;
  30.    }
  31.    
  32.    if(rv==true){
  33.        charge += 10;
  34.    }
  35.    
  36.    if(charge > 70 ){
  37.        charge = 70;
  38.    }
  39.    
  40.    return charge;
  41. }
  42. int main()
  43. {
  44.    string employeeName;
  45.    int hour;
  46.    bool rv;
  47.    double final_charge;
  48.    
  49.    getNameAndHoursParked(employeeName, hour);
  50.    rv = isVehicleNotAnRV();
  51.    final_charge = getFinalCharge(hour, rv);
  52.    
  53.    ofstream file;
  54.    file.open ("charge-report.txt");
  55.    file << "Customer name: " + employeeName + "\n";
  56.    file << "Parking charge $"<< final_charge;
  57.    file.close();
  58.    
  59.    return 0;
  60. }

Explanation:

Firstly, write the function getNameAndHoursParked to get employee name and number of parking hour. To enable pass by reference, the two parameters of this function are the reference variables (Line 6 - 11). These reference variables, name and hour, are associated with the variable employeeName and hour in the Main Program. Any values assigned to the two reference variables in the function will directly be set to employeeName and hour in the Main Program.

Next create a function isVehicleNotAnRV to enable user to input if a vehicle is a RV or not and return either true or false (Line 13 - 23).

Next create getFinalCharge function and create if else if statements to consider multiple parking hour options and apply the formula to calculate and return the total charge (Line 25 -45).

In the main program, declare all the required variables and call the functions to get all the required parking info (Line 49 - 56). Lastly output employee name and final charge to a file (Line 58 - 62).

You might be interested in
.. You should
Darya [45]

Answer:

C.

Explanation:

You want to make sure it still works. You don't want to move it periodically though in case of an emergency.

5 0
3 years ago
Read 2 more answers
A thin plastic membrane is used to separate helium from a gas stream. Under steady-state conditions the concentration of helium
Juli2301 [7.4K]

Answer:

N_A=1.5*10^-8 kmol/s.m^2

Explanation:

<u>KNOWN: </u>

Molar concentration of helium at the inner and outer surfaces of a plastic membrane. Diffusion coefficient and membrane thickness.  

<u>FIND:</u>

Molar diffusion flux.  

<u>ASSUMPTIONS:</u>

(1) Steady-state conditions, (2) One-dimensional diffusion in a plane wall, (3) Stationary medium, (4) Uniform C = C_A + C_B.  

<u>ANALYSIS:</u> The molar flux may be obtained from

 N_A=D_AB/L(C_A,1-C_A,2)

       =10^-9 m^2/s/0.001 m(0.02-0.005)kmol/m^3

N_A=1.5*10^-8 kmol/s.m^2

<u>COMMENTS:</u> The mass flux is:

n_A,x=M_a*N_A,x

n_A,x=6*10^-8 kg/s m^2

5 0
3 years ago
HELP! It’s for an architecture class on PLATO
vredina [299]

Answer:

ICC

Explanation:

The International Building Code (IBC) is a model building code developed by the International Code Council (ICC). It has been adopted for use as a base code standard by most jurisdictions in the United States.

7 0
3 years ago
Read 2 more answers
The worst case signal-to-noise ratio at the output of an FM detector occurs when: ________
AlexFokin [52]

Answer:

a. the desired signal is 90 degrees out of phase with the intelligence signal.

Explanation:

The signal to noise ratio of FM detector is defined as function of modulation index for SSB FM signal plus narrow band Gaussian noise at input. The ratio is usually higher than 1:1 which indicates more signals than noise.

6 0
3 years ago
A piston-cylinder assembly contains 0.5 lb of water. The water expands from an initial state where p1 = 40 lbf/in.2 and T1 = 300
VARVARA [1.3K]

Answer:

W = 31.393 Btu

Explanation:

given data

piston-cylinder assembly contains water = 0.5 lb

p1 = 40 lbf/in² = 40 × 144 lbf/ft²

T1 = 300° F

p2 = 14.7 lbf/in² = 14.7  × 144 lbf/ft²

pv 1.2 = constant.

solution

we use here superheated table A 4E  to get value for p1 = 40 and t = 300

v1 = 11.04 ft³/lbm

so we know

P_2 \times V_2^{1.2} = P_1 \times V_1^{1.2}    ,...............1

14.7 \times V_2^{1.2} = 40 \times (11.04)^{1.2}

solve it we get

v2 = 25.425 ft³/lbm

and here

W = (\frac{P_1V_1 - P_2V_2}{n-1}) m   ...............2

put here value we get

W = (\frac{40\times 144\times (11.04) -14.7 \times 144\times (25.425) }{1.2-1})0.5  

solve it we get

W = 31.393 Btu

5 0
3 years ago
Other questions:
  • provides steady-state operating data for a solar power plant that operates on a Rankine cycle with Refrigerant 134a as its worki
    12·1 answer
  • Technician A says that the first step in diagnosing engine condition is to perform a thorough visual inspection. Technician B sa
    8·1 answer
  • What are three common hazardous
    9·1 answer
  • Determine the magnitude of the resultant force and the moment about the origin. Note: the symbol near the 140 N-m moment are not
    15·1 answer
  • Who is the best musician in Nigeria<br>​
    11·2 answers
  • Please write the command(s) you should use to achieve the following tasks in GDB. 1. Show the value of variable "test" in hex fo
    5·1 answer
  • A cylinder with a frictionless piston contains 0.05 m3 of air at 60kPa. The linear spring holding the piston is in tension. The
    11·1 answer
  • The coolant heat storage system:
    10·1 answer
  • Engineers, scientists, and designers innovate products by taking apart existing
    6·1 answer
  • Lance is the sitting judge in the local family court. What education might have been
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!