QBasic Project 2

DECLARE SUB add ()
DECLARE SUB display ()
DECLARE SUB appendr ()
DECLARE SUB searchn ()
DECLARE SUB searchp ()
DECLARE SUB delete ()
DECLARE SUB bill ()
DECLARE SUB E ()
top:
CLS
PRINT TAB(35); “WELCOME”
PRINT TAB(25); “PROGRAM TO CALCULATE BILL”
PRINT “****************************************************************************”
PRINT TAB(35); “MENU”
PRINT “****************************************************************************”
PRINT TAB(30); “1.Create”
PRINT TAB(30); “2.View Records”
PRINT TAB(30); “3.Append Records”
PRINT TAB(30); “4.Search Records by name”
PRINT TAB(30); “5.Search Records by phone number”
PRINT TAB(30); “6.Delete Records”
PRINT TAB(30); “7.View telephone bill”
PRINT TAB(30); “8.Exit ”
color 6
PRINT “****************************************************************************”
INPUT ” Select your option (1/2/3/4/5/6/7/8)”; s
SELECT CASE s
CASE 1
CALL add
GOTO top
CASE 2
CALL display
GOTO top
CASE 3
CALL appendr
GOTO top
CASE 4
CALL searchn
GOTO top
CASE 5
CALL searchp
GOTO top
CASE 6
CALL delete
GOTO top
CASE 7
CALL bill
GOTO top
CASE 8
CALL E
CASE ELSE
BEEP
PRINT “INVALID CHIOCE”
INPUT “PRESS ANY KEY TO CONTINUE”; l$
GOTO top
END SELECT
PRINT “THANK YOU FOR USING THE PROGRAM”
END

SUB add
CLS
PRINT “CREATE YOUR DATA FILE NOW”
OPEN “telecell.txt” FOR OUTPUT AS #1
DO
INPUT “Enter id “; id%
INPUT “Enter name of customer”; nam$
INPUT “Enter telephone number”; tel$
INPUT “Enter alternative telephone number”; alt$
INPUT “Enter line type(Local/STD/ISTD)”; type$
INPUT “Enter company branch”; branch$
INPUT “Enter total number of calls”; c%
WRITE #1, id%, nam$, tel$, alt$, type$, branch$, c%
INPUT “Want to add more records(Y/N)”; ans$
ans$ = UCASE$(ans$)
LOOP WHILE ans$ = “Y”
CLOSE #1
INPUT “PRESS ANY KEY TO CONTINUE”; l$
END SUB

SUB appendr
CLS
PRINT “ADD MORE RECORDS NOW”
OPEN “telecell.txt” FOR APPEND AS #3
DO
INPUT “Enter id “; id%
INPUT “Enter name of customer”; nam$
INPUT “Enter telephone number”; tel$
INPUT “Enter alternative telephone number”; alt$
INPUT “Enter line type(Local/STD/ISTD)”; type$
INPUT “Enter company branch”; branch$
INPUT “Enter number of calls”; c%
WRITE #3, id%, nam$, tel$, alt$, type$, branch$, c%
INPUT”Want to add more records(Y/N)”; ans$
ans$ = UCASE$(ans$)
LOOP WHILE ans$ = “Y”
CLOSE #3
INPUT “PRESS ANY KEY TO CONTINUE”; l$
END SUB

SUB bill
CLS
PRINT “VIEWING TELEPHONE BILL NOW”
menu:
OPEN “telecell.txt” FOR INPUT AS #7
INPUT “Enter name of the person whose bill you want to view”; n$
dat$ = LEFT$(DATE$, 2)
IF dat$ = “1” THEN
m$ = “January”
ELSEIF dat$ = “2” THEN
m$ = “February”
ELSEIF dat$ = “3” THEN
m$ = “March”
ELSEIF dat$ = “4” THEN
m$ = “April”
ELSEIF dat$ = “5” THEN
m$ = “May”
ELSEIF dat$ = “6” THEN
m$ = “June”
ELSEIF dat$ = “7” THEN
m$ = “July”
ELSEIF dat$ = “8” THEN
m$ = “August”
ELSEIF dat$ = “9” THEN
m$ = “September”
ELSEIF dat$ = “10” THEN
m$ = “October”
ELSEIF dat$ = “11” THEN
m$ = “November”
ELSEIF dat$ = “12”THEN
m$ = “December”
END IF
DO WHILE NOT EOF(7)
f = 0
INPUT #7, id%, nam$, tel$, alt$, type$, branch$, c%
IF UCASE$(n$) = UCASE$(nam$) THEN
PRINT TAB(30); “BILL”
PRINT “****************************************************************************”
PRINT “CUSTOMER ID=”; id%
PRINT “CUSTOMER NAME=”; nam$
PRINT “TELEPHONE NUMBER=”; tel$
PRINT “ALTERNATIVE TELEPHONE; NUMBER = “; alt$
PRINT “LINE TYPE=”; type$
PRINT “COMPANY BRANCH=”; branch$
PRINT “NUMBER OF CALL MADE IN”; m$; “=”; c%
PRINT “****************************************************************************”
type$ = UCASE$(type$)
IF type$ = “LOCAL” THEN
t = c% * 2
ELSEIF type$ = “STD” THEN
t = c% * 3
ELSE
t = c% * 5
END IF
PRINT “TOTAL= Rs.”; t
EXIT DO
ELSE
f = 1
END IF
LOOP
CLOSE #7
IF f = 1 THEN PRINT “no record found”
INPUT “do u wanna check another? (y/n)”; zz$
IF UCASE$(zz$) = “Y” THEN
GOTO menu
ELSE
INPUT “PRESS ANY KEY TO CONTINUE”; l$
END IF
END SUB

SUB delete
CLS
PRINT “DELETE REQUIRED RECORDS NOW ”
ans$ =”y”
WHILE LCASE$(ans$) = “y”
OPEN “telecell.txt” FOR INPUT AS #6
OPEN “temp2.txt” FOR APPEND AS #7
INPUT “Enter name of the person whose records need to be deleted”; n$
DO WHILE NOT EOF(6)
INPUT #6, id%, nam$, tel$, alt$, type$, branch$, c%
IF UCASE$(n$) <> UCASE$(nam$) THEN
WRITE #7, id%, nam$, tel$, alt$, type$, branch$, c%
f = 1
ELSE
f = 0
EXIT DO
END IF
LOOP
CLOSE #6, #7
KILL “telecell.txt”
NAME “temp2.txt” AS “telecell.txt”
IF f <> 0 THEN
PRINT “Name not found”
ELSE
PRINT “Record is deleted”
END IF
INPUT “Do you want to delete more records (Y/N)”; ans$
WEND
INPUT “PRESS ANY KEY TO CONTINUE”; l$
END SUB

SUB display
CLS
OPEN “telecell.txt” FOR INPUT AS #2
dat$ = LEFT$(DATE$, 2)
IF dat$ = “1” THEN
m$ = “January”
ELSEIF dat$ = “2” THEN
m$ = “February”
ELSEIF dat$ = “3” THEN
m$ = “March”
ELSEIF dat$ = “4” THEN
m$ = “April”
ELSEIF dat$ =”5″ THEN
m$ = “May”
ELSEIF dat$ = “6” THEN
m$ = “June”
ELSEIF dat$ = “7”THEN
m$ =”July”
ELSEIF dat$ = “8” THEN
m$ = “August”
ELSEIF dat$ = “9” THEN
m$ = “September”
ELSEIF dat$ = “10” THEN
m$ = “October”
ELSEIF dat$ = “11” THEN
m$ = “November”
ELSEIF dat$ = “12” THEN
m$ =”December”
END IF
WHILE NOT EOF(2)
INPUT #2, id%, nam$, tel$, alt$, type$, branch$, c%
CLS
PRINT “VIEWING RECORDS NOW”
PRINT “CUSTOMER ID=”, id%
PRINT “CUSTOMER NAME=”, nam$
PRINT “TELEPHONE NUMBER=”, tel$
PRINT “ALTERNATIVE TELEPHONE NUMBER=”, alt$
PRINT “LINE TYPE=”, type$
PRINT “COMPANY BRANCH=”, branch$
PRINT “NUMBER OF CALL MADE IN “; m$;”=”; c%

INPUT ” PRESS ANY KEY TO CONTINUE”; l$
WEND
CLOSE #2

END SUB

SUB E
CLS
PRINT “EXITING THE PROGRAM”
PRINT “PROGRAM DEVELOPED BY:”
PRINT “…………………………………”
PRINT “CLASS :10”
PRINT “SCHOOL NAME””
END SUB

SUB searchn
CLS
ans$ = “Y”
WHILE ans$ = “Y”
OPEN “telecell.txt” FOR INPUT AS #4
INPUT “Enter the name you want to search”; n$
dat$ = LEFT$(DATE$, 2)
IF dat$ = “1” THEN
m$ = “January”
ELSEIF dat$ = “2” THEN
m$ = “February”
ELSEIF dat$ = “3” THEN
m$ = “March”
ELSEIF dat$ = “4” THEN
m$ = “April”
ELSEIF dat$ = “5” THEN
m$ = “May”
ELSEIF dat$ = “6” THEN
m$ = “June”
ELSEIF dat$ = “7”THEN
m$ = “July”
ELSEIF dat$ = “8” THEN
m$ = “August”
ELSEIF dat$ = “9” THEN
m$ = “September”
ELSEIF dat$ = “10” THEN
m$ = “October”
ELSEIF dat$ = “11” THEN
m$ = “November”
ELSEIF dat$ = “12” THEN
m$ = “December”
END IF
DO WHILE NOT EOF(4)
f = 0
INPUT #4, id%, nam$, tel$, alt$, type$, branch$, c%
IF UCASE$(n$) = UCASE$(nam$) THEN
PRINT “CUSTOMER ID=”; id%
PRINT “CUSTOMER NAME=”; nam$
PRINT “TELEPHONE NUMBER=”; tel$
PRINT “ALTERNATIVE TEEPHONE NUMBER=”; alt$
PRINT “LINE TYPE=”; type$
PRINT “COMPANY BRANCH=”; branch$
PRINT “NUMBER OF CALL MADE IN “; m$; “=”; c%
EXIT DO
ELSE
f = 1
END IF
LOOP
CLOSE #4
IF f = 1 THEN PRINT “NO RECORD FOUND”
INPUT “Do you want to search more records(Y/N)”; ans$
ans$ = UCASE$(ans$)
WEND
INPUT “PRESS ANY KEY TO CONTINUE”; l$
END SUB

SUB searchp
CLS
ans$ = “Y”
WHILE ans$ = “Y”
OPEN “telecell.txt” FOR INPUT AS #5
INPUT “Enter the phone number you want to search”; p$
dat$ = LEFT$(DATE$, 2)
IF dat$ = “1” THEN
m$ = “January”
ELSEIF dat$ = “2” THEN
m$ = “February”
ELSEIF dat$ = “3” THEN
m$ = “March”
ELSEIF dat$ = “4” THEN
m$ = “April”
ELSEIF dat$ = “5” THEN
m$ = “May”
ELSEIF dat$ = “6” THEN
m$ = “June”
ELSEIF dat$ = “7” THEN
m$ = “July”
ELSEIF dat$ = “8” THEN
m$ =”August”
ELSEIF dat$ = “9”THEN
m$ = “September”
ELSEIF dat$ = “10” THEN
m$ = “October”
ELSEIF dat$ = “11” THEN
m$ =”November”
ELSEIF dat$ = “12”THEN
m$ = “December”
END IF
DO WHILE NOT EOF(5)
f = 0
INPUT #5, id%, nam$, tel$, alt$, type$, branch$, c%
IF tel$ = p$ OR alt$ = p$ THEN
PRINT “CUSTOMER ID=”; id%
PRINT “CUSTOMER NAME=”; nam$
PRINT “TELEPHONE NUMBER=”; tel$
PRINT “ALTERNATIVE TELEPHONE NUMBER=”; alt$
PRINT “LINE TYPE=”; type$
PRINT “COMPANY BRANCH=”; branch$
PRINT “NUMBER OF CALL MADE IN “; m$; “=”; c%
EXIT DO
ELSE
f = 1
END IF
LOOP
CLOSE #5
IF f = 1 THEN PRINT “NO RECORD FOUND”
INPUT “Do you want to search more records(Y/N)”; ans$
ans$ = UCASE$(ans$)
WEND
INPUT “PRESS ANY KEY TO CONTINUE”; l$
END SUB