Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Wednesday, 16 January 2013

Suppose that electricity costs 4.75 cents per kilowatt hour, and that a surcharge of 10% is added to the bill. A city utility tax is 3% is also levied;however no tax is charged on the surcharge, and no surcharge is added for the tax. A penalty for a late payment is 4% of the total bill. Write the java program that computes an electric bill (by Maria sh)

import java.util.Date;
import java.util.Scanner;

public class ElectricityBill 
* 4.75 cents per KiloWatt per hour 
* Surcharge 10%
* City utility tex 3%
* 4% of total bill charged on late payment 
public static void main(String[] args) 
int totalUnits;
double billCharged;
Scanner in = new Scanner(;
Scanner ins = new Scanner(;
Date date = new Date();
System.out.print("Enter total units consumed (in KiloWatt) = ");
totalUnits = in.nextInt();
billCharged = totalUnits*4.75;
System.out.println("Day of month = "+date.getDate());
if (date.getDate()> 10)
billCharged += billCharged * (0.10+0.04);
billCharged += billCharged *(0.03);
System.out.println("Your total bill = "+billCharged);


Note that 10th of each month is assumed to be the due date of bill payment. If any customer pays bill after due date, 10% surcharge and 4% of total bill on late payment will be charged.

No comments:

Post a Comment