Problem

In this exercise, you modify the electric bill program from Lab10-2. a. If necessary,...

In this exercise, you modify the electric bill program from Lab10-2.

a. If necessary, create a new project named Advanced23 Project. Copy the instructions from the Lab10-2.cpp file into a source file named Advanced23.cpp. (Alternatively, you can enter the instructions from Figure 10-31 into the Advanced23.cpp file.) Change the filename in the first comment to Advanced23.cpp.

b. Modify the program so that it allows the user to display the electric bill for more than one customer without having to run the program again. Use a sentinel value to end the program. The sentinel value should be entered as the current meter reading in the getInput function. When the user enters the sentinel value, the getInput function should not prompt the user to enter the previous reading.

c. Change the getInput function to a value-returning function. If the user does not enter a sentinel value as the current reading, the getInput function should prompt the user to enter the previous reading. It then should return a value that indicates whether the current and previous readings are valid or invalid. To be valid, the current reading must be greater than or equal to the previous reading. The main function should not call the cal cBill or display Bill functions when the readings are not valid. Instead, it should display an error message.

d. Save and then run the program. Enter 3000 and 2000 as the current and previous readings. The program should display 1000 and $90.00 as the units used and total charge, respectively, and then prompt you to enter the current reading. Now enter 3000 and 5000 as the current and previous readings. The program should display an error message and then prompt you to enter the current reading. Enter 53512 and 51875 as the current and previous readings. The program should display 1637 and $147.33 as the units used and total charge, respectively. Enter your sentinel value to end the program.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT