Hi I'm writting this code to prepare electricity for as many users as there are input. I don't got when I compile it always shows something where the "if" start. I need a fresh look please. Thanks
import java.text.*; // format output
import java.util.*; // Scanner class
public class electricBill
{
public static void main(String[] args)
{
DecimalFormat num=new DecimalFormat("$,###.00"); // Create format for name num.
// variable names
double amountDue; // amount charge to customer
double chargeRate; // charge rate depend on kwh used
double oldMeter; // previous meter reading
double newMeter; // current meter reading
double kwhUsed; // the eclectricity used
int accountNum; //customer account number
String str; // to hold user name input
char repeat; // to hold yes or no, 'Y' or 'N'
System.out.println("This program calculates the "+"customer elecitricity usage "+"and the amount due "+"of Peco electric company.");
// Initialize Scanner to read from DOS window.
Scanner input = new Scanner(System.in);
// Get as many different mortgage payments as the user wants.
do
{
// Read numbers from the DOS window.
System.out.print("Enter the Customer name: ");
str = input.nextLine();
System.out.print("Enter the customer account number: ");
accountNum = input.nextInt();
System.out.print("Enter the new meter reading: ");
newMeter = input.nextDouble();
System.out.print("Enter the old meter reading: ");
oldMeter = input.nextDouble();
if(kwhUsed <= 300)
{
chargeRate=5.00;
}
else if(kwhUsed<= 1000)
{
chargeRate= 5.00+(0.03*(kwhUsed-300));
}
else if(kwhUsed>= 1001)
{
chargeRate= 35.00+(0.02*(kwhUsed-1000));
}
// Compute the the current electriciity usage.
kwhUsed= (newMeter- oldMeter);
// compute the current electricity usgae charge
amountDue= (kwhUsed*chargeRate);
// Display the customer information on the DOS window.
System.out.println(str+", "+"account number "+accountNum+". Last meter reading "+oldMeter+", current meter reading "+newMeter+". The total usage of "+kwhUsed+" kwh used"+"will be charge "+num.format(amountDue)+" for this period.");
System.out.println(); //Prints a blank line.
// As many users as there are input
System.out.println("Would you like to prepare another bill "+"for the next customer ?");
System.out.print("Enter Y for Yes or N for No: ");
str=input.next(); // Read next char
repeat=str.charAt(0); // Get the first char.
} while (repeat=='Y' || repeat=='y');
System.out.println("Good-Bye!");
}
}