Please write a Java Program: Problem: Southwest Power and Light provides electri
ID: 3592579 • Letter: P
Question
Please write a Java Program:
Problem:
Southwest Power and Light provides electricity at the basic rate of $ 0.10 per kilowatt for the months December through February, 0.12 per kilowatt for the months of March through May, and 0.15 per kilowatt for the remaining months.
Customer billing is divided into three tiers or rate zones: 0-350 kilowatts, 351 – 500 kilowatts, and above 500 kilowatts. Usage up to 350 kilowatts is billed at the basic rate. Usage between 350 and 500 kilowatts is billed at 10% above the basic rate. Above 500, billing is 25% above the basic rate. These surcharges apply only to the usage falling within the respective rate tier.
Input and Output The dialog should begin with “Southwest Power and Light” and “Billing Statement” and finish with the information shown. Your program will provide the corresponding values where usage, unit charges, and totals are shown. At the end of each bill, the program should ask the user if another bill is to be calculated and prompt for Yes or No. If Yes, perform the above session again. If No, the program will provide a suitable message (i.e., Thank you) and end.
Be sure to clearly label all output.
Input: Your name (Last, First I.)
Meter reading date (mm/dd/yyyy)
Electricity used (KW)
Output:
Date printed
Your name
Meter reading date (mm/dd/yyyy)
Electricity used (KW)
Detailed charges by tier Total bill $ In the above, dates should be displayed in mm/dd/yyyy format. Billing amounts should be shown in $ x,xxx.xx format with decimal alignment and all values rounded to the nearest cent. Totals must be correct. Test Data and Calculations Use the following table of the test data and the expected results. This table may be done using a spreadsheet program or word processor. Test your program for each of the cases shown. Assign values for Test No. 10 of your own choosing. In the last column, indicate Yes or No, as to whether or not your program's calculated values agree with these expectations. Your program must validate inputs for meter reading date and kilowatts used. When an invalid input is detected, allow the user to correct the entry.
Southwest Power & Light
Billing Statement
Please enter your name (Last, First) > Bailey, R.
Meter reading date > 2/15/2017
Electricity Used (KW) > 550
Date printed: 10/6/2017
Name: Bailey, R.
Meter reading date: 2/15/2017
Electricity Used (KW): 550
Baseline charge $ 35.00
Over-baseline charge $ 16.50
Excess charge $ 6.25
Total amount due: $ 57.75
Calculate another bill (Y/N)?
N Thank you for letting us serve you!
Test Table Test No. Meter Date KW Used Baseline Charge OverBaseline Charge Excess Charge Total Charge Correct (Y/N) 1 2/15/17 225 $ 22.50 $ - $ - $ 22.50 2 2/15/17 375 35.00 2.75 - 37.75 3 2/15/17 550 35.00 16.50 6.25 57.75 4 4/15/17 225 27.00 - - 27.00 5 4/15/17 375 42.00 3.30 - 45.30 6 4/15/17 550 42.00 19.80 7.50 69.30 7 8/15/17 225 33.75 - - 33.75 8 8/15/17 375 52.50 4.13 - 56.63 9 8/15/17 550 52.50 24.75 9.38 86.63 10 ? ?
Explanation / Answer
import java.util.*;
class ComputeElectricityBill
{
public static void main(String args[])
{
int units=280;
double billpay=0;
if(units<100)
{
billpay=units*1.20;
}
else if(units<300)
{
billpay=100*1.20+(units-100)*2;
}
else if(units>300)
{
billpay=100*1.20+200*2+(units-300)*3;
}
System.out.println("Bill to pay : " + billpay);
}
}