The document outlines an assignment for creating a program that calculates electricity bills based on units consumed. It describes the algorithm for determining charges, including a fixed service charge of ₹200, and provides a structured approach to implementing the solution in a class named 'ElectricityBill'. The program categorizes the charges based on consumption brackets: less than 100 units, between 100 and 200 units, and over 200 units.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
10 views
Assignment 4
The document outlines an assignment for creating a program that calculates electricity bills based on units consumed. It describes the algorithm for determining charges, including a fixed service charge of ₹200, and provides a structured approach to implementing the solution in a class named 'ElectricityBill'. The program categorizes the charges based on consumption brackets: less than 100 units, between 100 and 200 units, and over 200 units.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6
ASSIGNMENT
ASSIGNMENT DATE: 17. 11. 2022
PROGRAM DESCRIPTION An Electricity Company charges their consumers according to the units consumed per month according to the given traffic:
In addition to the above, every consumer has to pay
₹ 200 as Service Charge per month. Write a program to input the amount of units consumed and calculate the total charges payable (Bill) by the consumer. ALGORITM STEP 1: Start STEP 2: Define class “ElectricityBill” STEP 3: Define a method calc with return type void STEP 4: Input the amount of Units Consumed STEP 5: End of method calc STEP 6: Define a method display with return type void STEP 7: Initialize ch as double datatype with initial value 0.0 STEP 8: If units consumed is less than 100 units then the charge will be (u*2.0) STEP 9: Else STEP 10: If units consumed is within 200 units then the charge will be (100*2.0)+(u-100)*1.80 STEP 11: Else STEP 12: If units consumed is greater than 200 units then the charge will be (100*2.0)+(100*1.80)+(u-200)*1.50 STEP 13: End of if block STEP 14: Total charge will be ch+200.0 as the extra 200 rupees is the service tax paid each month with the Electricity bill STEP 15: End of method Display STEP 14: Define main method with return type void STEP 15: Creating an object STEP 16: Calling the method calc STEP 17: End of main method STEP 18: End of class SOURCE CODE: OUTPUT VARIABLE LISTING