Question: Write a function (and a program that uses it) that calculates these charges for a given amount of time spent charging per month on a

Write a function (and a program that uses it) that calculates these charges for a given amount of time spent charging per month on a given network. The charges should be returned as a 'double' type.

For the network fee structures, there are three options:

  • Network 1 has a monthly fee of $10, plus $1.00 per hour of charging.
  • Network 2 has no monthly fee and costs $2.50 per hour of charging.
  • Network 3 has a monthly fee of $20, plus $0.50 per hour of charging.

Function should have a prototype:

double calculateCharges(double, int);

These values are:

  • The first parameter (a 'double') is the total amount of charging hours expected (this does not have to be a whole number -- can be a floating point number like '1.5', meaning 1 hour and 30 minutes).
  • The second parameter (an 'int') is the number 1, 2 or 3 indicating which network should be used for the calculation.
  • The return value (a 'double') is the total expected cost to charge.

The program should prompt the user (and accept input for) the number of expected hours charging, and output:

  • Expected charges for each of the three networks (with a precision of 2 digits past the decimal point), and
  • The lowest cost network.

Example Output:

Your program does not need to loop and accept multiple entries, it can accept one number, output the results, and exit. Below are 3 different example runs.

Enter the expected number of hours charging: 10.3 Your expected costs are: Network 1: $20.30 Network 2: $25.75 Network 3: $25.15 The lowest cost network is Network 1.
Enter the expected number of hours charging: 21.8 Your expected costs are: Network 1: $31.80 Network 2: $54.50 Network 3: $30.90 The lowest cost network is Network 3.
Enter the expected number of hours charging: 2.2 Your expected costs are: Network 1: $12.20 Network 2: $5.50 Network 3: $21.10 The lowest cost network is Network 2.

In C++ please. Thank you!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!