Page 216 - ComputerScience_Class_11
P. 216
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
bill_amt = (100*2.25) + (250 * 3.50) + (250* 4.75) + (unit_con
29 - 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:
BlueJ: Terminal Window - Java
Options
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 Write a above Java program using if statement.
1 import java.util.*;
2 class Bill_Electricity
3 {
4 public static void main(String args[])
5 {
214 Touchpad Computer Science (Ver. 3.0)-XI

