Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Java Program To Calculate Electricity Bill 

A simple Java program to Calculate Electricity Bill. Multiply the wattage of the gadget by the number of hours it is used per day. Multiply by 1000. Subtract your kWh rate from the total. If else is a conditional Statement in programming that executes a separate series of statements based on whether an expression is true or false.

Class in Java

A class is a user-defined blueprint or prototype that is used to build things. It denotes the collection of attributes or methods that are shared by all objects of the same type.

Nested If Statement in Java

A nested if statement is an if statement that is the target of another if or else statement. An if statement nested within another if statement is referred to as a nested if statement. Yes, we may stack if statements within if statements in Java.

Double Keyword in Java

The keyword double denotes the 64-bit float primitive type. The programming language java. lang. When you need to store a double value but also an object reference, the double class is the nominal wrapper class. 

Else If Statement in Java

The if-else statement in C is used to perform operations in response to a series of circumstances. The if block’s activities are carried out only if and only if the provided condition is true.

The if/else if statement can be used to generate a chain of if statements. The if statements are evaluated in order until one of the if expressions is true or the if/else if chain is complete. No code blocks are run if there is no true expression at the end of the if/else if chain. 

Java Program To Calculate Electricity Bill

class Main
{ 
public static void main(String args[]) 
{ 
int unit=500;
double bill=0;
if(unit300)
{
bill=100*1.20+200*2+(unit-300)*3;
}
System.out.println("Electric bill calculator" + bill); 
} 
}

Output:

Electric bill calculator1120.0

Free online notepad with sharing and printing option without login. Our main moto is to make users comfortable with our notepad to take notes.

The post Java Program To Calculate Electricity Bill  appeared first on Inlarn.



This post first appeared on Inlarn, please read the originial post: here

Share the post

Java Program To Calculate Electricity Bill 

×

Subscribe to Inlarn

Get updates delivered right to your inbox!

Thank you for your subscription

×