import java.util.Scanner;
import java.text.DecimalFormat;
public class ElectricCharges {
public static void main(String[] args) {
double charges, totalCharges=0, averageCharge;
int startReading=0, endReading=0, usage, totalUsage=0, avergeUsage, count=0, flag=0;
//Creating object of Scanner class for standard input
Scanner stdin = new Scanner(System.in);
DecimalFormat df = new DecimalFormat(".00"); //used to print output upto 2 decimal places
String cont = "yes";
do { //Reading month from user
System.out.print("Please enter the month for the reading: ");
String month = stdin.next();
month = month.toUpperCase(); //Converting into month uppercase
//Taking input beginning meter reading from user
System.out.print("Please enter the beginning meter reading: ");
startReading = stdin.nextInt();
//validating user input
if(startReading<=0) {
System.out.println("I'm sorry, meter readings must be greater than 0.\n");
System.out.print("Would you like to enter another reading? : ");
cont = stdin.next();
if(cont.equals("yes"))
continue;
}
//Taking input ending meter reading from user
if(cont.equals("yes")) {
System.out.print("Please enter the ending meter reading: ");
endReading = stdin.nextInt();
//validating user input
if(endReading <= startReading) {
System.out.println("I'm sorry, the ending meter readings must be greater than starting meter reading.\n");
System.out.print("Would you like to enter another reading? : ");
cont = stdin.next();
if(cont.equals("yes"))
continue;
}
}
if(cont.equals("yes")) {
usage = endReading - startReading; //calculating usage
System.out.println("\nThe usage for this period: "+usage+" kWh");
//calculating charges based on condition
if(month.equals("JULY") || month.equals("AUGUST") || month.equals("SEPTEMBER") ) {
if(usage<=100) {
charges = .46*usage;
System.out.println("The charges for this month for 100 kWh at 46 cents per kWh: $"+df.format(charges)+" USD");
}
else {
charges = .46*100 + .52*(usage-100);
System.out.println("The charges for this month for 100 kWh at 46 cents/kWh and "+(usage-100)+" kWh overage at 52 cents/kWh: $"+df.format(charges)+" USD");
}
}
else {
if(usage<=100) {
charges = .42*usage;
System.out.println("The charges for this month for 100 kWh at 42 cents per kWh: $"+df.format(charges)+ " USD");
}
else {
charges = .42*100 + .48*(usage-100);
System.out.println("The charges for this month for 100 kWh at 42 cents/kWh and "+(usage-100)+" kWh overage at 48 cents/kWh: $"+df.format(charges)+" USD");
}
}
totalUsage = totalUsage + usage; //calculating total usage
totalCharges = totalCharges + charges; //calculating total cjatges
count++; //counter value to keep track of number of bill input
flag=1;
System.out.print("\nWould you like to enter another reading? : ");
cont = stdin.next();
}
}while(cont.equals("yes"));
//Printing total bill details of all months
if(flag==1) {
avergeUsage = totalUsage/count;
averageCharge = totalCharges/count;
System.out.print("\nTotal Usage: "+ totalUsage+" kWh.");
System.out.print(" Total charges for the "+count+" months of readings: $"+ df.format(totalCharges));
System.out.print(" Your average usage is "+avergeUsage+" kWh, ");
System.out.println("and your average charge is $"+df.format(averageCharge)+" per month");
}
}
}

JAVA *REFER TO THE PICTURES* Summary Write a program that will calculate the monthly electric charges...
computer programming
Write a C program that will calculate and print monthly water bills. The total units consumed per month are derived from subtracting the previous meter readings with the current meter reading. The charges are calculated based on the rates stated in Table 2. The sample output is shown in Figure 16 Tulis aturcara Cyang akan mengira dan mencetak bil air bulanan Jumlah unit yang diguna sebulan dikira dengan menolak bacaan meter sebelum dengan bacaan meter terkinl. Caj dikira...
The electric company charges according to the following rate schedule: 9 cents per kilowatt-hour (kwh) for the first 300 kwh 8 cents per kwh for the next 300 kwh (up to 600 kwh) 6 cents per kwh for the next 400 kwh (up to 1000 kwh) 5 cents per kwh for all electricity used over 1000 kwh Write a program that would repeatedly read in a customer number (an integer) and the usage for that customer in kwh (an integer)....
I submited this question before but they didnt follow the requirements/contraints or format...they didnt use methods. Please use comments. Write a JAVA program that will ask for the customer’s last and current meter reading in Kilowatt Hours (KwHs). Determine the amount of usage for the month and calculate a subtotal (before tax) and a total amount due (tax included) using the following constraints. Constraints Rate A: For 500 KwHs or less = $0.0809 / KwH Rate B: For 501 to 900...
Write a program in c++ for An electric company came out with a residential rate schedule in your state. You are asked to write a program that will compute the customer’s electric bill. Program will prompt month number and Kilowatt hour used. Sample Input Screen: Enter the month (1 - 12) : Kilowatt hours used : The electric bill is computed using the following method: There is a flat service charge of $15.31...
write a program in java that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and a dollar, in a 5-cent increments(25,30,35.....,90,95,or 100), and the machine accepts only a single dollar bill to pay for the item. for example a possible dialogue with the user might be "Enter price of item (from 25 cents to a dollar, in 5-cent increments):45 you boughtan item for 45 cents and gave me...
Q2.1) Write a program to calculate phone bill of the user. The rule to calculate bill is given as follows: • You should ask the option to the user at first. If the phone bill will be calculated with internet connection option, user must enter 1, otherwise user must enter O. Do all necessary controls and take the number from the user until the user enters one of the correct options. (1 or 0). • Design 2 different methods. Both...
***** JAVA ONLY ***** Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. Frist the program should ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the...
JAVA Programming . Description: For an unknown number of employees: prompt and receive payroll data; calculate gross pay, taxes owed, and net pay; and display a pay stub. Input : Prompt and receive input from the user for the following: /// Employee’s First and Last Name /// Hours Worked /// Pay Rate /// Overtime Rate Multiplier ** For the Employee’s First and Last Name: Both data items must be read in one prompting into one...
Using Python write a code for Function 1: A bank charges $10 per month plus the following check fees for a commercial checking account: a. $0.10 each for 1-19 checks b. $0.08 each for 20-39 checks c. $0.06 each for 40-59 checks d. $0.04 each for 60 or more checks. (Note that the same fee is charged for all checks. If the customer writes 21 checks, all 21 checks are billed at the $0.08 rate.) The bank also charges an...
Write a complete C++ program that creates a monthly bill for the text messaging. Your cell phone company provides the following three text messaging plans. Package A: Two Thumbs. For $9.95 per month, 100 text messages are allowed. Additional text messages are 15 cents each. Package B: All Thumbs. For $14.95 per month, 200 text messages are allowed. Additional text messages are 10 cents each. Package C: Lightning Thumbs. For $19.95 per month, unlimited text messaging is provided. State sales...