Exp (2) - 1
Exp (2) - 1
QUESTION :
Develop a Java application to generate Electricity bill. Create a class with the following
members:
Consumer no., consumer name, previous month reading, current month reading,
and type of EB connection (i.e domestic or commercial).
Compute the bill amount using the following tariff:If the type of the EB connection is domestic,
calculate the amount to be paid as follows:
First 100 units – Free 101-200 units - Rs. 2.50 per unit 201 -500 units - Rs. 4 per unit 501 units -
Rs. 6 per unit
If the type of the EB connection is commercial, calculate the amount to be paid as follows:
First 100 units – Free 101-200 units - Rs. 4.50 per unit 201 -500 units - Rs. 6 per unit 501 units -
Rs. 7 per unit
CODE:
import java.util.Scanner;
class ElectricityBill {
this.consumerNo = consumerNo;
this.consumerName = consumerName;
this.previousReading = previousReading;
this.currentReading = currentReading;
this.connectionType = connectionType;
double amount = 0;
if (connectionType.equalsIgnoreCase("domestic")) {
unitsConsumed = 500;
unitsConsumed = 200;
} else if (connectionType.equalsIgnoreCase("commercial")) {
unitsConsumed = 500;
}
unitsConsumed = 200;
return amount;
bill.displayBill();
scanner.close();
INPUT :
OUTPUT: