Electircity bill counter | Program in java abut for bill


//Written in Java By Syed Ali Haider
//Student of The Hajvery University,Lahore, Pakistan.
//Don't remove these lines for legal use
//For more Please contact us.
package elect_bill;// package

import java.util.Scanner; // import

public class Bill { // class
      
       public static int calc (int units)
      
       { // calc function start from here
             
              if (units == 0) // if user enter zero
                     System.out.println("Something wrong....You enterZero.");
             
              else if (units <0) // if user enter negative value
                     System.out.println("Something wrong.......You ente a negative value.");
             
              else if (units <= 300) // if the units are less than 300
              {
                     int bill=(units*5) + 250;
                     return bill;
              }
             
              else if (units > 300) //if the units are more than 300
              {
                     int bill=(units*7) + 250;
                     return bill;
              }
             
              return 0;     // only for error handling purpose
              } // cals function end here
      
      
      
       public static void main(String[] args)
       {// main function start from here
      
              Scanner input = new Scanner (System.in);
             
              System.out.print("Please enter the unit comsumed: ");

              int unit=input.nextInt();
             
              int payable_bill=calc(unit);
      
       System.out.println("Your Payable bill is : Rs."+payable_bill);


input.close();      
             
              }// ending of main function
}// ending of class

//Written in Java By Syed Ali Haider
//Student of The Hajvery University,Lahore, Pakistan.
//Don't remove these lines for legal use
//For more Please contact us.

Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System