Page 168 - computer science (868) class 11
P. 168
22 else
23 if(unit_con<=350)
24 bill_amt = (100 * 2.25)+(unit_con-100)*3.50;
25 else
26 if(unit_con<=600)
27 bill_amt = (100*2.25) + (250 * 3.50) + (unit_con-350)* 4.75;
28 else
29 bill_amt = (100*2.25) + (250 * 3.50) + (250* 4.75) + (unit_con
- 600) * 6;
30 System.out.println("\tSTATE ELECTRICITY BOARD");
31 System.out.println("Month : "+mon_name);
32 System.out.println("Name of Consumer : "+ cus_name);
33 System.out.println("Previous Meter Reading : "+ pr_read);
34 System.out.println("Current Meter Reading : "+cur_read);
35 System.out.println("Amount : " + bill_amt);
36 }
37 }
The output of the preceding program is as follows:
Enter the month for which the amount is to be calculated : JUNE
Enter the name of the consumer : RAM KRISHNA SAHA
Enter the previous meter reading : 345
Enter the current meter reading : 678
STATE ELECTRICITY BOARD
Month : JUNE
Name of the Consumer : RAM KRISHNA SAHA
Previous Meter Reading : 345
Current Meter Reading : 678
Amount : 1040.5
Program 3 The above program can be done using if statement also.
1 import java.util.*;
2 class Bill_Electricity
3 {
4 public static void main()
5 {
6 Scanner sc= new Scanner(System.in);
7 String mon_name, cus_name;
166166 Touchpad Computer Science-XI

