1. Bihar State electricity board calculates electricity bill for their consumers according to the
units consumed(per month Jas per the given tarif
Units consumed
charges
Uplo 100 units
R9 180/unit
More than 100 units & upto 300 units
R8, 230/unit
More than 300 units & upto 500 units
Rs 2 80/unit
More than 500 units
RSS 50/unil
Wnte a program to input name of the
consumer consumer
number month and units consumed
Calculate and display the electricity bill with al the details
Answers
Answer:
import java.util.Scanner;
public class KboatElectricBill
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Consumer Name: ");
String name = in.nextLine();
System.out.print("Enter Unit's Consumed: ");
int units = in.nextInt();
double amt = 0.0;
if (units <= 200)
amt = units * 3.8;
else if (units <= 300)
amt = (200 * 3.8) + ((units - 200) * 4.4);
else if (units <= 400)
amt = (200 * 3.8) + (100 * 4.4) + ((units - 300) * 5.1);
else
amt = (200 * 3.8) + (100 * 4.4) + (100 * 5.1) + ((units - 400) * 5.8);
System.out.println("Consumer Name: " + name);
System.out.println("Units Consumed: " + units);
System.out.println("Bill Amount: " + amt);
Answer:
import java.util.Scanner;
public class KboatElectricBill
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Consumer Name: ");
String name = in.nextLine();
System.out.print("Enter Unit's Consumed: ");
int units = in.nextInt();
double amt = 0.0;
if (units <= 200)
amt = units * 3.8;
else if (units <= 300)
amt = (200 * 3.8) + ((units - 200) * 4.4);
else if (units <= 400)
amt = (200 * 3.8) + (100 * 4.4) + ((units - 300) * 5.1);
else
amt = (200 * 3.8) + (100 * 4.4) + (100 * 5.1) + ((units - 400) * 5.8);
System.out.println("Consumer Name: " + name);
System.out.println("Units Consumed: " + units);
System.out.println("Bill Amount: " + amt);
Explanation: