Question
The electric company charges according to the following rate schedule: 9 cents per kilowatt-hour (kwh) for the first 300 kwh 8 cents per kwh for
The electric company charges according to the following rate schedule:
9 cents per kilowatt-hour (kwh) for the first 300 kwh 8 cents per kwh for the next 300 kwh (up to 600 kwh) 6 cents per kwh for the next 400 kwh (up to 1000 kwh) 5 cents per kwh for all electricity used over 1000 kwh
Write a program that would repeatedly read in a customer number (an integer) and the usage for that customer in kwh (an integer). The program should include a method to compute the total charge for each customer. Use the following template for the method:
// takes kwh and calculates the total charge for that customer. public static double findCharge(int kwh){ // put your code here }
The program should terminate when the user enters a sentinel value of -999 for the customer number. The program should print a three-column chart listing the customer number, the kilowatt-hours used, and the total charge for each customer. The program should also compute and print the number of customers, the total kilowatt-hours used, and the total charges. Use a JTextArea component within a JOptionPanedialog box to display the output. Note that you should not use arrays.
Sample Output: Input Please enter a customer number or -999 to quit: 1001 OK Cancel Input Please enter the usage in KWH 250 OK Cancel Message Customer No. Usage in Kwh. Total Charges 1001 1002 1003 1004 250 350 650 2000 22.50 31.00 54.00 125.00 3250 232.50 OKStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started