Beruflich Dokumente
Kultur Dokumente
1)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,
type
of EB connection (i.e domestic or commercial). Compute the bill amount using the following tariff. If the
follows:
Aim:
To create a Java console application used to generate electricity bill based on connection type (Domestic
and Commercial) and consumption. Both are having different tariff slots.
Algorithm:
Step 2 Get the user informations [Name, Consumer Number, Reading’s of previous and currentmonth,
Connection Type]
Step 3 Compute units consumed by user [Current Month Reading – Previous Month Reading]
Step 4 Check the connection type
Program:
import java.io.*;
import java.util.*;
class ComputeElectricityBill
int cnum;
long units1;
long units2;
long units;
cname=sc.nextLine();
int choice;
choice=sc.nextInt();
units1=sc.nextLong();
units2=sc.nextLong();
units=units1+units2;
double billpay=0;
switch(choice)
case 1:
if(units<=100)
billpay=units*1.00;
billpay=units*2.50;
billpay=units*4;
else if(units>=501)
billpay=units*6;
break;
case 2:
if(units<=100)
billpay=units*2.00;
billpay=units*4.50;
billpay=units*6;
else if(units>=501)
billpay=units*7;
break;
default:
System.out.println("Inappropriate Option");
}
Output:
xyz
123
250
520