Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that will ask for the customers last and current meter reading in Kilowatt Hours (KwHs). Determine the amount of usage for the

Write a program that will ask for the customers last and current meter reading in Kilowatt Hours (KwHs). Determine the amount of usage for the month and calculate a subtotal (before tax) and a total amount due (tax included) using the following constraints.

Constraints

Rate A: For 500 KwHs or less = $0.0809 / KwH

Rate B: For 501 to 900 KwHs = $0.091 / KwH

Rate C: For greater than 900 KwHs = $0.109 / KwH

Utilities Tax is 3.46% regardless of usage.

Requirements

Create a separate (external to the main class) subclass MyUtility()

Rate and tax variables should be private to the subclass

Use a constructor to initialize the default reading values to 0

Use another constructor to set the reading values

Use set and get methods in MyUtility() to determine the usage, rate, subtotal, tax, and final bill

Format all output as follows:

o Usage to 1 decimal place, KhWs o Rate to 4 decimal places, monetary o Subtotal to 2 decimal places, monetary o Taxes to 2 decimal places, monetary o Total to 2 decimal places, monetary

Implement a loop to return and enter new values (run the program again) if the user wishes to Hints

Set methods can do all the computation

Set methods can call other set methods

The type of loop can be of your choosing

Make sure you use Java coding conventions

Expected Output

Below is a sample run with three iterations. User input is in bold.

Welcome to the City Power Bill Calculator! Please enter your previous meter reading: 750 Please enter your current meter reading: 1250

Your usage was: 500.0 KwHs Your rate was: $0.0809/KwH Your subtotal is: $40.45 Taxes are: $1.40 Your total bill this month is: $41.85

Would you like to calculate a new usage? (Y for Yes, N to exit): y

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions