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
A wastewater treatment plant has two primary clarifiers, each 20m in diameter with a 2-m side-water depth. the effluent weirs ar
jasenka [17]

Answer:

overflow rate 20.53 m^3/d/m^2

Detention time 2.34 hr

weir loading  114.06 m^3/d/m

Explanation:

calculation for single clarifier

sewag\  flow Q = \frac{12900}{2} = 6450 m^2/d

surface\  area =\frac{pi}{4}\times diameter ^2 = \frac{pi}{4}\times 20^2

surface area = 314.16 m^2

volume of tankV  = A\times side\ water\ depth

                             =314.16\times 2 = 628.32m^3

Length\ of\  weir = \pi \times diameter of weir

                       = \pi \times 18 = 56.549 m

overflow rate =v_o = \frac{flow}{surface\ area} = \frac{6450}{314.16} = 20.53 m^3/d/m^2

Detention timet_d = \frac{volume}{flow} = \frac{628.32}{6450} \times 24 = 2.34 hr

weir loading= \frac{flow}{weir\ length} = \frac{6450}{56.549} = 114.06 m^3/d/m

6 0
3 years ago
Write a program to control the operation of the RED/GREEN/BLUE LED (LED2) as follows: 1. If no button is pressed, the LED should
aalyn [17]

Answer:

See explaination

Explanation:

int RED=10; int BLUE=11; int GREEN=12; int BUTTON1=8; int BUTTON2=9; void setup() { pinMode(RED, OUTPUT); pinMode(BLUE, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(BUTTON1, INPUT); pinMode(BUTTON2, OUTPUT); } void loop() { int BTN1_STATE=digitalRead(BUTTON1); int BTN2_STATE=digitalRead(BUTTON2); if(BTN1_STATE==HIGH) { digitalWrite(BLUE, HIGH); delay(1000); // Wait for 1 second digitalWrite(BLUE, LOW); } if(BTN2_STATE==HIGH) { digitalWrite(RED, HIGH); delay(4000); // Wait for 4 seconds digitalWrite(RED, LOW); } if(BTN1_STATE==HIGH && BTN2_STATE==HIGH) { digitalWrite(GREEN, HIGH); delay(2000); // Wait for 2 second digitalWrite(GREEN, LOW); } }

4 0
3 years ago
Engineered lumber should not be used for
Dimas [21]

Answer:

Composite panel garage doors

Explanation:

8 0
2 years ago
A 1 turn coil carries has a radius of 9.8 cm and a magnetic moment of 6.2 X 10 -2 Am 2. What is the current through the coil?
Alexus [3.1K]

Answer:

The current through the coil is 2.05 A

Explanation:

Given;

number of turns of the coil, N = 1

radius of the coil, r = 9.8 cm = 0.098 m

magnetic moment of the coil, P = 6.2 x 10⁻² A m²

The magnetic moment is given by;

P = IA

Where;

I is the current through the coil

A is area of the coil = πr² = π(0.098)² = 0.03018 m²

The current through the coil is given by;

I = P / A

I = (6.2 x 10⁻² ) / (0.03018)

I = 2.05 A

Therefore, the current through the coil is 2.05 A

6 0
4 years ago
Cavitation usually occurs because:
IgorLugansk [536]

Answer:

B) the liquid accelerated to high velocities.

<em>I</em><em> </em><em>hope</em><em> </em><em>this helps</em><em> </em>

3 0
3 years ago
Other questions:
  • Vapor lock occurs when the gasoline is cooled and forms a gel, preventing fuel flow and
    7·2 answers
  • A Carnot engine is operated between two heat reservoirs at temperatures of 520 K and 300 K. It receives heat from the 520 K rese
    8·1 answer
  • How can the direction of rotation of a split-phase motor be changed? *
    15·2 answers
  • The following median grain size data were obtained during isothermal liquid phase sintering of an 82W-8Mo-8Ni-2Fe alloy. What is
    15·1 answer
  • Different metabolic control systems have different characteristic time scales for a control response to be achieved. Match the t
    6·1 answer
  • What is the chord length of an airplane called?
    14·1 answer
  • Cite another example of information technology companies pushing the boundaries of privacy issues; apologizing, and then pushing
    9·1 answer
  • This might count as engineering, I'm not sure as this is IT
    8·1 answer
  • What is the process pf distributing and selling clean fuel?​
    6·1 answer
  • Develop a simple Business plan as an entrepreneur​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!