You are on page 1of 2


* Program to compute user's electric bill. User is prompted for account,

* identification and billing information by text queries shown on the system
* console. Set price for electricity is multiplied by user input number of
* units used to obtain price of service. Results are
* printed to the console. This program does not handle exceptions or contain
* any input restrictions not provided by the Java system proper.
* Use at your own risk!!!
* @author (Thomas Rates)
* @version (1.0 Due/Date/2010)

import java.util.Scanner; //Dependency for the Scanner method.

public class ConsoleBilling99

double KILO_WATT_COST = .0624; //Global Constant Rate per KWH

public static void main (String[] args){

Scanner in = new Scanner (;

//Creates new input Scanner.

String Name, Address, Acct; //Variables Needed by Program

double Total, KWH, Rate = .0624; //Gettin' Fancy Already, I'm must bee a Genius!

// Part Two

System.out.print ("Enter Your Account Number: ");

// Console prompts user for input.
Acct =;
// Stores user input into String variable Acct

System.out.print("Enter Your First And Last Name: ");

// Same method. Different variable being initialized.
Name =;
// Save variable for use in next section of program

System.out.print("Enter Your Complete Address: ");

Address =;

System.out.print("Enter Kilowatt Hours Used: ");

KWH = in.nextDouble();

System.out.println("Calculating Bill...\n");

/*Use code \n to create a line break, then carriage return, */

/* producing a blank line for all to see.*/
Total = KWH * Rate ; //The only calculation. Wonder if he's lonely? Ask him. I dare you.

System.out.println("Your account number is: "+Acct+"\n");

System.out.println("Your bill is : $" + Total + "\n");

System.out.println("Account: " + Total + "\n");

System.out.println("Customer Name: " + Name + "\n"); // You didn't really ask him, did you?

System.out.println("Customer Address: " + Address + "\n");

System.out.println("Total KWH Used: " + KWH + "\n"); // Well?

System.out.println("Amount Due: " + Total); //Printing Variable Total, Calculated Above