Create a procedure or function to calculate electricity bill as per the following criteria: For first 100 units: Rs. 5 per unit For 101-150 units: Rs. 7 per unit For 151-300 units: Rs. 7.50 per unit For 301 onward units: Rs. 8 per unit

PROGRAM:-


Declare
units number;
totalElectricitBill number;
PROCEDURE electricity_bill(u IN number, Bill OUT number) IS
Begin
IF(u <=100) THEN
Bill:=u*5;
ELSIF (u<=150) THEN
Bill:=(100*5)+(u-100)*7;
ELSIF (u<=300) THEN
Bill:=(100*5)+(50*7)+(u-150)*7.50;
ELSIF (u>=301) THEN
Bill:=(100*5)+(50*7)+(150*7.50)+(u-300)*8;
END IF;
End;
BEGIN
units:=400;
totalElectricitBill:=0;
electricity_bill(units,totalElectricitBill);
dbms_output.put_line('Total Electricity Bill is: '||totalElectricitBill); 

Output:-

WHEN 150 UNITS WERE USED:-

WHEN 200 UNITS WERE USED:-

WHEN 400 UNITS WERE USED:-


Comments