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 have a bin wrench turning a 1/2 13 UNC bolt. You overcome 1200 lbs of resistance when you
andrew11 [14]

Fr

is my guess but yeah

6 0
3 years ago
# line 1 age = int(input("Enter your age: ")) # line 3 print("Invalid input") If we want the computer to display "Invalid input"
user100 [1]

Answer:

Insert

'try:' at line 1

'except:' at line 3

Explanation:

The "try and except" commands in Python are used for exception handling.

try: the statements under this block are executed normally

except: the the statements under this block are executed when there is an exception.

We can use these commands to handle errors, for example, in the given scenario we don't want the user to enter a floating point number such as

1.5, 2.6 etc.

When the user enters an integer number then the except command is not executed.

When the user enters a floating point number then the except command is executed, program is stopped and error message is shown that is at line 4

Python code:  

# line 1

try:

# line 2

   age = int(input("Enter your age: "))

# line 3

except:

# line 4

   print("Invalid input")

Output:

Test 1:

Enter your age: 20

Test 2:

Enter your age: 20.5

Invalid input

5 0
3 years ago
Engineers will redesign their products when they find flaws. TRUE O False​
nataly862011 [7]

Answer:

true

Explanation:

6 0
3 years ago
It is desired to produce and aligned carbon fiber-epoxy matrix composite having a longitudinal tensile strength of 610 MPa. Calc
julia-pushkina [17]

Answer:

volume fraction of fibers is 0.4

Explanation:

Given that for the aligned carbon fiber-epoxy matrix composite:

Diameter (D) = 0.029 mm

Length (L) = 2.3 mm

Tensile strength (\sigma_{cd}) = 610 MPa

fracture strength (\sigma_f) = 5300 MPa

matrix stress (\sigma_m) =  17.3 MPa

fiber-matrix bond strength (\tau_c) = 19 MPa

The critical length is given as:

L_C=\sigma_f(\frac{D}{2\tau_c} )=5300*10^6(\frac{0.029*10^{-3}}{19*10^6} )=8.1*10^{-3}=8.1mm

Since the critical length is greater than the length, the aligned carbon fiber-epoxy matrix composite can be produced.

The longitudinal strength is given by:

\sigma_{cd}=\frac{L*\tau_c}{D} .V_f+\sigma_m(1-V_f)

making Vf the subject of the formula:

V_f=\frac{\sigma_{cd}-\sigma_m}{\frac{L*\tau_c}{D} -\sigma_m}

Vf is the volume fraction of fibers.

Therefore:

V_f=\frac{\sigma_{cd}-\sigma_m}{\frac{L*\tau_c}{D} -\sigma_m}=\frac{610*10^6-17.3*10^6}{\frac{2.3*10^{-3}*19*10^6}{0.029*10^{-3}}-17.3*10^6} } =0.4

volume fraction of fibers is 0.4

8 0
3 years ago
Cleaning the shop's floor is being discussed. Technician A says to flush the waste and dust into a floor drain. Technician B say
lawyer [7]

Answer:

Technician B

Explanation:

A HEPA or high-efficiency particulate Type filter is capable of capturing 99 percent of particles that are 2 microns or larger, high-efficiency particulate airsuch as pet dander and DUST. So this is the best answer. I hope you find this helpful!

4 0
3 years ago
Other questions:
  • A higher grade number for oil means it is _____.
    6·2 answers
  • What is the composition, in atom percent, of an alloy that contains 44.5 lbmof Ag, 83.7 lbmof Au, and 5.3 lbmof Cu? What is the
    9·1 answer
  • How dose iorn get forged itno steel?
    10·1 answer
  • I have a stream with three components, A, B, and C, coming from another process. The stream is 50 % A, and the balance is equal
    11·1 answer
  • An intranet is a restricted network that relies on Internet technologies to provide an Internet-like environment within the comp
    11·1 answer
  • Let m be an integer in the set {0,1,2,3,4,5,6,7,8, 9}, and consider the following problem: determine m by asking 3-way questions
    12·1 answer
  • Select the correct answer.
    8·1 answer
  • 5.You are designing the fit for two bearings. For each case, specify the maximum and minimum hole and shaft diameter:a.A journal
    12·1 answer
  • Describe three examples of how metrology can improve the safety of automobiles.
    12·1 answer
  • The evaporator:
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!