QBasic Programming

In order to discourage heavy consumption of electricity, the electricity board charges the following rates

First 80 units:   Rs 4 per unit
Next 60 units: Rs 6 per unit
Above that :     Rs 7 per unit
Every user has to pay a minimum charge of Rs. 100 irrespective of the total amount of electricity consumed. In case total consumption is more than 300 units an additional charge of 10% is added. WAP to read consumer’s name, units consumed and print out total amount to pay along with name of consumer.


CLS
INPUT "ENTER NAME OF A CUSTOMER"; N$
INPUT "ENTER UNIT CONSUMED"; U
IF U <= 80 THEN
C = U * 4
ELSEIF U >= 81 AND U <= 140 THEN
C = 80 * 4
C1 = (U - 80) * 6
ELSE
C = 80 * 4
C1 = 60 * 6
C2 = (U - 140) * 7
END IF
T = 100 + C + C1 + C2
PRINT "NAME OF CUSTOMER"; N$
PRINT "TOTAL UNIT CONSUMPTION"; U
PRINT "TOTAL AMOUNT"; T
END

USING SUB PROCEDURE

DECLARE SUB TOTAL(N$, U)
CLS
INPUT "ENTER NAME OF A CUSTOMER"; N$
INPUT "ENTER UNIT CONSUMED"; U
CALL TOTAL (N$, U)
END

SUB TOTAL (N$, U)
IF U <= 80 THEN
C = U * 4
ELSEIF U >= 81 AND U <= 140 THEN
C = 80 * 4
C1 = (U - 80) * 6
ELSE
C = 80 * 4
C1 = 60 * 6
C2 = (U - 140) * 7
END IF
T = 100 + C + C1 + C2
PRINT "NAME OF CUSTOMER"; N$
PRINT "TOTAL UNIT CONSUMPTION"; U
PRINT "TOTAL AMOUNT"; T
END SUB

WAP to input total number of words and compute telegram charges which are as follows (Prev Lesson)
(Next Lesson) WAP to supply percentage from the keyboard and print division using sub – program. Use the following conditions
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!