An electric company measures the amount of electricity its customers use in kilo
ID: 3871228 • Letter: A
Question
An electric company measures the amount of electricity its customers use in kilowatt-hours (kwh) and charges them according to the following schedule:
Electricity Used Charge
First 12 kwh or less $2.80
Next 78 kwh $0.08 kwh
Above 90 kwh $0.10 each kwh
The minimum bill is $2.80. So if a customer uses 5 kwh, the charge is $2.80. If the customer uses 50 kwh, the charge is $2.80 for the first 12 kwh and $.08 for the rest. The bill for that customer is therefore
Bill = 2.80 + .08 * (50-12) = 5.84
Design a program to calculate and print customers’ bills.
2. The charge for a local telephone call depends on the area to which the call is made and the call’s duration. One telephone company’s charges are as follows.
Call Area
Charge for the First Minute
Charges for Each Additional Minute
A
8.7 cents
0
B
10.6 cents
2.9 cents
C
14.4 cents
4.8 cents
D
18.3 cents
5.8 cents
Design a program that accepts the area to which a call was made and its duration, then calculates and prints the charge for that call. Beep the speaker and print an error message of an invalid area is entered. Use Switch/case structure.
A health club has many membership categories, and two of those categories receive discounts. Category G members receive a 20 percent discount, and category S member receive a 10 percent discount. The other membership categories receive no discount. Design a program that accepts a membership category and bill, then calculates and prints the discount price, discount, and the net bill. Category Q is not used, so you can use that as trailer data. Use Switch/case structure.
There are three seating categories at a stadium. For a Softball game, Class A seats cost $15, Class B seats cost $12, and Class C seats cost $9. Design a program that asks how many tickets for each class of seats were sold, and then displays the amount of income generated from ticket sales. Use Switch/case structure.
JAVA PROGRAMMING
ANY PROGRAMMING LANGUAGE
Call Area
Charge for the First Minute
Charges for Each Additional Minute
A
8.7 cents
0
B
10.6 cents
2.9 cents
C
14.4 cents
4.8 cents
D
18.3 cents
5.8 cents
Explanation / Answer
import java.util.*;
class ComputeElectricityBill
{
public static void main(String args[])
{
int units,;
Scanner sc=new Scanner(System.in);
System.out.println("enter number of units");
units=sc.nextInt();
double billpay=0;
if(units<=12)
{
billpay=2.80;
}
else if(units<78)
{
billpay=2.80 + .08*(units-12);
}
else if(units>90)
{
billpay=2.80 + .10*(units-78);
}
System.out.println("Bill to pay : " + billpay);
}
}
------------------------------------------------------------------------------------------
import java.util.Scanner;
public class TelephoneBill {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double duration = 0;
double billpay=0;
String area = "" ;
while(area !="Z" ) {
System.out.println("Enter the area");
area = input.nextString();
switch (area) {
case A:
System.out.println("Enter the Duration");
duration = input.nextDoube();
billpay = 8.7
System.out.println("Total phone bill is"+billpay);
break;
case B:
System.out.println("Enter the Duration");
duration = input.nextDoube();
billpay = 10.6 + 2.9*(duration - 1);
System.out.println("Total phone bill is"+billpay);
break;
case C:
System.out.println("Enter the Duration");
duration = input.nextDoube();
billpay = 14.4 + 4.8*(duration - 1);
System.out.println("Total phone bill is"+billpay);
break;
case D:
System.out.println("Enter the Duration");
duration = input.nextDoube();
billpay = 18.3 + 5.8*(duration - 1);
System.out.println("Total phone bill is"+billpay);
break;
default:
System.out.println("Invalid are entered");
break;
}
}
}
}
------------------------------------------------------------------------
import java.util.Scanner;
public class MembershipCategory {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double bill = 0;
double discount=0;
double netbill=0;
String category = "" ;
while(category !="0"){
System.out.println("Enter the category");
category = input.nextString();
switch (category) {
case G:
System.out.println("Enter the bill");
bill = input.nextDoube();
discount=bill *.20;
netbill = bill-discount;
System.out.println("bill :"+bill +"netbill :"+netbill +"discount :"+discount);
break;
case S:
System.out.println("Enter the bill");
bill = input.nextDoube();
discount=bill *.10;
netbill = bill-discount;
System.out.println("bill :"+bill +"netbill :"+netbill +"discount :"+discount);
break;
Case Q:
System.out.println("Invalid are category");
break;
Default :
System.out.println("Enter the bill");
bill = input.nextDoube();
netbill = bill;
discount=0;
System.out.println("bill :"+bill +"netbill :"+netbill +"discount :"+discount);
break;
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.