Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Electrical Consumptions The electricity accounts of residents in a very small town are calculated as follows If 500 units or fewer are used, the cost

image text in transcribed

Electrical Consumptions The electricity accounts of residents in a very small town are calculated as follows If 500 units or fewer are used, the cost is 2 cents per unit If more than 500 but not more than 1000 units are used, the cost is $10 for the first 500 units and 5 cents for every unit in excess of 500 If more than 1000 units are used, the cost is $35 for the first 1000 units plus 10 cents for every unit in excess of 1000 . .A basic service fee of $5 is charged, no matter how much electricity is used. Write a class called Consumptions that contains instance data that represent five residents' electrical consumptions. Define the Consumptions constructor to accept and initialize five consumption Vales. Include a method that uses a for loop to calculate the total charge for each consumption and also redefine the Java tostring method so that it returns a nicely formatted one or multi-line description of the consumptio consumptions from the standard input stream and also instantiate and update a Consumptions object. The main method should include code to test the object's methods n charges. Create a driver class whose main method allows the user to enter five Test your program with the following values: 200, 500, 700, 1000, and 1500. Results: $9.00, $15.00, $25.00, $40.00, $90.00

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions