Java

Electricity Bill Calculation using Java Application

This tutorils teach Electricity Bill Calculating based on the below conditions step by step

  1. First 100 units: $0.10 per unit
  2. Next 200 units (101 to 300): $0.15 per unit
  3. Above 300 units: $0.20 per unit

 

This is code of the project

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) 
{                                         
        int unitcal = Integer.parseInt(txtUnit.getText());
        double totalbill = calBill(unitcal);
        txtBill.setText(String.format(" $%.2f", totalbill));
}                                        

    int units;
    private static double calBill(int units)
    {
        double totbill = 0.0;
        
        if(units <= 100)
        {
            totbill = units * 0.10;
        }
        else if(units <= 300)
        {
            totbill = 100 * 0.10 + (units -100) * 0.15;
        }
        else
        {
             totbill = 100 * 0.10 +  200 * 0.15 + (units -300) * 0.25;
        }
        return totbill;
    }

 

 

 

 

admin

Recent Posts

Employee Working Hours Calculation System using C#.net

Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…

3 days ago

Java Payroll System Calculate Employee Overtime

Act as a Java developer to create a program that calculates the gross wage for…

5 days ago

Employee Working Hours Calculation System using Java

Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…

5 days ago

Laravel 11 School Management System

In this tutorial, we will teach you how to create a simple school management system…

2 weeks ago

How to Make Admin Panel Using React MUI

I have design the Admin Basic templete using React MUI Design Admin Dashboard and Login.Here…

3 weeks ago

Install Laravel Breeze for Authentication Using Laravel 11

In this tutorial ,i am to going teach the Laravel Breeze.Laravel Breeze provides a simple…

4 weeks ago