
Write a program that will print out a hydro bill. The bill will be formatted as the example on the next page. The following information will be entered by the user: - Account number (12 digit code) - Address - Kilowatts used for the month for evening useage - Kilowatts used for the month for daytime useage - Kilowatts used for the month for nighttime useage - Kilowatts used for the month for morning useage Layout specifications - Overall width of bill is 80 characters Time of Use Rates - Morning rates, $0.08 kWh - Daytime rates, $0.099 kWh - Evening rates, $0.08 kWh - Nighttime rates, $0.053 kWh Formulas ? Total Cost = Kilowatts x Time of Use Rate ? Taxes = Total Cost x 15% ? Total Payable = Total Cost + Taxes

Hi Friend,
Try the following code:
import java.util.*;
import java.text.*;
public class HydroBill{
public static void main(String[]args){
DecimalFormat df = new DecimalFormat("$###,###.## ");
Scanner input=new Scanner(System.in);
System.out.print("Enter Account Number: ");
long accno=input.nextLong();
System.out.print("Enter Address: ");
String address=input.next();
System.out.print("Kilowatts used for the month for morning usage: ");
double mkw=input.nextDouble();
System.out.print("Kilowatts used for the month for daytime usage: ");
double dkw=input.nextDouble();
System.out.print("Kilowatts used for the month for evening usage: ");
double ekw=input.nextDouble();
System.out.print("Kilowatts used for the month for nighttime usage: ");
double nkw=input.nextDouble();
double totalMorningRate=mkw*0.08;
double totalDayRate=mkw*0.099;
double totalEveingRate=mkw*0.08;
double totalNightRate=mkw*0.053;
double total=totalMorningRate+totalDayRate+totalEveingRate+totalNightRate;
double taxes=total*0.15;
double totalPayable=total+taxes;
System.out.println("Amount Payable is: "+df.format(totalPayable));
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.