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

Banking Loan Calculation Project using Java

This tutorials series we are going to talk about how to make a banking loan…

20 hours ago

Build Crud App with Laravel 11 and Vue.js

In this tutorial will teach Vue Laravel 10 CRUD using Vite step by step. Laravel …

1 week ago

Bakery Management System Project using Java

This tutorial will teach you how to make a Bakery Management System Project using Java…

2 weeks ago

Student Rank Calculation System using Java

In this tutorial i am going to teach the Rank Calculation System using Java step…

2 weeks ago

Implementing Admin and User Authentication in Laravel 11: A Comprehensive Tutorial

Laravel, a widely-used PHP framework, keeps getting better. Its latest version, Laravel 11, now offers…

3 weeks ago

Laravel 11 CRUD Mastering RESTful API MVC with Repository Pattern

In this tutorial will teach Laravel 11 Api MVC with Repository Pattern Crud Application step…

2 months ago