Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Saturday, 5 November 2011

Develop a java program to generate the Electricity bill. The program have three member functions, Getdata(): to accept the block number, flat name, name and number of units, Calc(): calculate the total cost, Display(): display the bill in proper format ( name, units , total charges). If the total is greater than RM 150 then additional surcharge 15% is added (by Fikri Fieda)


import java.util.*;
class ebill
{
public static void main (String args[])
{
customerdata ob = new customerdata();
ob.Getdata();
ob.Calc();
ob.Display();

}
}

class customerdata
{
Scanner in = new Scanner (System.in);
Scanner ins = new Scanner (System.in);
String cname,fname;
int bn;
double units,tbill;

void Getdata()
{
System.out.print ("\n\t Enter block number = ");
bn = in.nextInt();
System.out.print ("\n\t Enter flate name = ");
fname = ins.nextLine();
System.out.print ("\n\t Enter customer name = ");
cname = ins.nextLine();
System.out.print ("\n\t Enter total consumed units = ");
units = in.nextDouble();
}

void Calc()
{
if (units<100)
tbill=0.40*units;
else if (units>100 && units<300)
tbill=0.50*units;
else
tbill=0.60*units;
if (tbill>150)
tbill+=tbill*0.15;
}

void Display()
{
System.out.println ("\n\t Customer name = "+cname);
System.out.println ("\n\t Total units = "+units);
System.out.println ("\n\t Total bill = RM "+tbill);
}
}

8 comments:

  1. Hey there I am so thrilled I found your weblog, I really found you by accident, while I was researching on Google for something else,
    Anyhow I am here now and would just like to say thanks
    for a tremendous post and a all round entertaining blog (I also love the
    theme/design), I don’t have time to look over it all
    at the minute but I have book-marked it and also added your
    RSS feeds, so when I have time I will be back to read a lot more,
    Please do keep up the superb work.
    Also visit my web page :: professional forex signals

    ReplyDelete
  2. Hi! This is kind of off topic but I need some help from an established blog.

    Is it very difficult to set up your own blog? I'm not very techincal but I can figure things out pretty fast. I'm thinking about making my own but I'm not sure where to start. Do you have any tips or suggestions? Many thanks
    Also visit my webpage : Dr Charles DC

    ReplyDelete
  3. i need to do tracking of the electricity bill. how will i do that please help. urgent. show how to create it...

    ReplyDelete
  4. i need electricity bill tracking status code i.e(creating a file,searching a file ,check wether the customer cleared his last months due or not,displaying coustomers record) help me please

    ReplyDelete