answersLogoWhite

0

import java.io.*;

import java.lang.*;

class electricity extends Exception

{

int b1;

electricity(int b)

{

b1=b;

System.out.println("\n\t\t Exception will caught below ");

}

}

class electric

{

static void compute(int a,int b,String name,String bno)throws IOException,electricity

{

name=name;

bno=bno;

if(b<a)

throw new electricity(b);

else

{

int tmr,amt=0,z=0;

tmr=b-a;

do

{

DataInputStream in=new DataInputStream(System.in);

System.out.println("\n\t Click any purpose ");

System.out.println("\n\t\t 1-Domestic ");

System.out.println("\n\t\t 2-Agriculture ");

System.out.println("\n\t\t 3-Industry ");

System.out.println("\n\t\t 4.Exit");

System.out.println("\n\n\t\t Enter ur Choice :");

int ch=Integer.parseInt(in.readLine());

switch(ch)

{

case 1:

if(tmr<=100)

amt =tmr *2;

else if(tmr >100 && tmr <=200)

amt=(tmr-100) *4 +100*2;

System.out.println("\n\n\t\t **********************************************");

System.out.println("\t\t\t Electricity Bill Preparation ");

System.out.println("\t\t **********************************************\n\n");

System.out.println("\n\t\t Name : " +name + " Bill no : " + bno );

System.out.println("\n\t\t Previous Meter Reading : " +a );

System.out.println("\n\t\t Closed Meter Reading :" +b );

System.out.println("\n\t\t Current Meter Reading :" +tmr );

System.out.println("\n\t\t Purpose : Domestic " );

System.out.println("\n\t\t Total Amount Rs. :" +amt );

break;

case 2:

if(tmr<=100)

amt =tmr *0;

else if(tmr >100 && tmr<=200)

amt=(tmr-100) *1 +100*0;

System.out.println("\n\n\t\t **********************************************");

System.out.println("\t\t\t Electricity Bill Preparation ");

System.out.println("\t\t **********************************************\n\n");

System.out.println("\n\t\t Name : " +name + " Bill no : " + bno );

System.out.println("\n\t\t Previous Meter Reading : " +a );

System.out.println("\n\t\t Closed Meter Reading :" +b );

System.out.println("\n\t\t Current Meter Reading :" +tmr );

System.out.println("\n\t\t Purpose : Agriculture " );

System.out.println("\n\t\t Total Amount Rs. :" +amt );

break;

case 3:

if(tmr<=100)

amt =tmr *4;

else if(tmr >100 && tmr<=200)

amt=(tmr-100) *8 +100*4;

System.out.println("\n\n\t\t **********************************************");

System.out.println("\t\t\t Electricity Bill Preparation ");

System.out.println("\t\t **********************************************\n\n");

System.out.println("\n\t\t Name : " +name + " Bill no : " + bno );

System.out.println("\n\t\t Previous Meter Reading : " +a );

System.out.println("\n\t\t Closed Meter Reading :" +b );

System.out.println("\n\t\t Current Meter Reading :" +tmr );

System.out.println("\n\t\t Purpose : Industry " );

System.out.println("\n\t\t Total Amount Rs. :" +amt );

break;

case 4:

System.exit(0);

}

System.out.println("\n\t Continue :");

z=Integer.parseInt(in.readLine());

} while(z==1);

}

}

public static void main(String ar[])throws IOException

{

electric ee=new electric();

String name,bno;

int pmr,cmr;

DataInputStream in=new DataInputStream(System.in);

System.out.println("\n\t ELECTRICITY BILL USING USERDEFINED EXCEPTION ");

System.out.print("\n\t\t Enter the name : ");

name=in.readLine();

System.out.print("\n\t\t Enter the Bill Number :");

bno=in.readLine();

System.out.print("\n\t\t Previous Meter Reading : ");

pmr=Integer.parseInt(in.readLine());

System.out.print("\n\t\t Current Meter Reading : ");

cmr=Integer.parseInt(in.readLine());

try

{

compute(pmr,cmr,name,bno);

}

catch(Exception e)

{

System.out.println("\n\t\tUserDefined Exception is found");

}

}

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Is heating included as part of the electricity bill?

Heating is not typically included in the electricity bill. Heating is usually a separate expense that is paid for separately, either through a gas bill or another heating source.


What is the journal entry of electricity bill?

Debit electricity expensesCredit cash / bank


What are some powers that the national and state governments?

preparation of bill signing of bill


Telephone bill program written in java source codes?

I Want the Java Coding For Creating Phone Bill &amp; Customer Name &amp; Her Details, Plz Send The Coding For Creating Phone Bill, Thank You Regards Suresh


What is the journal entry for electricity bill paid in cheque?

debit electricity billcredit bank


What is journal posting on electricity bill?

how do i post electricity bill owe for 4 months back


What is the average electricity bill in Ohio?

The average electricity bill in Ohio varies depending on the type of home you live in. The average electricity bill can range from $30 for an apartment to $90.


What is the average electricity bill for people in Britain?

The average electricity consumption is 4,800 kWh per is average UK electricity bill is &pound;669.60


What is the order for bill to become a law?

Bill preparation. The House Member (or the Congressman/woman) prepares and drafts the bill.


What is the correct order for a bill to become?

Bill preparation. The House Member (or the Congressman/woman) prepares and drafts the bill.


How do solar lights affect electricity bills?

Solar lights affect the electricity bill by reducing the cost of the bill. It is used to help someone not to have a high electricity bill. These are very good lights.


How does an electrical bill work?

You get the bill. If you pay it, the electricity stays on; if you don't pay it, the electricity gets turned off.