QBasic Programming

WAP to input number of passengers and their destination

The program should calculate the total bus fare and the discount amount according to the following conditions.
Rates for the different destinations:
Destinations                             Rate
Pokhara                                    450 per person
Butwal                                     500 per person
Chitwan                                   300 per person
Discount Rate
If the number of passenger is 5 or above then discount=5% in the total amount.


Solution:
CLS
INPUT "ENTER NO. OF PASSENGER"; P
INPUT "ENTER DESTINATIONS"; D$
IF UCASE$(D$) = "POKHARA" THEN
T = P * 450
ELSEIF UCASE$(D$) = "BUTWAL" THEN
T = P * 500
ELSEIF UCASE$(D$) = "CHITWAN" THEN
T = P * 300
END IF
IF P >= 5 THEN D = 5 / 100 * T
F = T - D
PRINT "TOTAL BUS FARE="; F
END

USING SUB PROCEDURE

DECLARE SUB TOTAL(P, D$)
CLS
INPUT "ENTER NO. OF PASSENGER"; P
INPUT "ENTER DESTINATIONS"; D$
CALL TOTAL (P, D$)
END

SUB TOTAL (P, D$)
IF UCASE$(D$) = "POKHARA" THEN
T = P * 450
ELSEIF UCASE$(D$) = "BUTWAL" THEN
T = P * 500
ELSEIF UCASE$(D$) = "CHITWAN" THEN
T = P * 300
END IF
IF P >= 5 THEN D = 5 / 100 * T
F = T - D
PRINT "TOTAL BUS FARE="; F
END SUB

WAP to convert hexadecimal number to decimal number (Prev Lesson)
(Next Lesson) WAP to input total number of words and compute telegram charges which are as follows
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!