2) WAP to display records from "Book.txt", where language used is "Nepali"
3) WAP to display records from "Book.txt", where price of a book is between 500 to 1000.
4) WAP to display records from "Book.txt", where published year is 2015 and author name starts with letter "N"
5) WAP to copy records from "Book.txt" to "Eng.txt" file where language used is "English"
1)
OPEN "BOOK.TXT" FOR OUTPUT AS #1
CLS
DO WHILE UCASE$(CH$)="Y"
INPUT "ENTER BOOK NAME";BN$INPUT "ENTER AUTHOR NAME";AN$
INPUT "ENTER PRICE"; P
INPUT "ENTER PUBLISHED YEAR"; PY
INPUT "ENTER LANGUAGE OF THE BOOK";L$
WRITE #1, BN$, AN$, P, PY, L$
INPUT "DO YOU WANT TO ADD MORE (Y/N)"; CH$
LOOP
CLOSE #1
END
2)
OPEN "BOOK.TXT" FOR INPUT AS #1
CLS
PRINT "BOOKNAME", "AUTHORNAME", "PRICE","YEAR","LANGUAGE"
WHILE NOT EOF(1)
INPUT #1, BN$, AN$, P, PY, L$
IF UCASE$(L$)="NEPALI" THEN
PRINT BN$, AN$, P, PY, L$
END IF
WEND
CLOSE #1
END
3)
OPEN "BOOK.TXT" FOR INPUT AS #1
CLS
PRINT "BOOKNAME", "AUTHORNAME", "PRICE","YEAR","LANGUAGE"
WHILE NOT EOF(1)
INPUT #1, BN$, AN$, P, PY, L$
IF P>=500 AND P<=1000 THEN
PRINT BN$, AN$, P, PY, L$
END IF
WEND
CLOSE #1
END
4)
OPEN "BOOK.TXT" FOR INPUT AS #1
CLS
PRINT "BOOKNAME", "AUTHORNAME", "PRICE","YEAR","LANGUAGE"
WHILE NOT EOF(1)
INPUT #1, BN$, AN$, P, PY, L$
N$=LEFT$(AN$,1)
IF PY=2015 AND UCASE$(N$)="N" THEN
PRINT BN$, AN$, P, PY, L$
END IF
WEND
CLOSE #1
END
END IF
WEND
CLOSE #1
END
5)
OPEN "BOOK.TXT" FOR INPUT AS #1
OPEN "ENG.TXT" FOR OUTPUT AS #2
CLS
WHILE NOT EOF(1)
INPUT #1, BN$, AN$, P, PY, L$
IF UCASE$(L$)="ENGLISH" THEN
WRITE #2, BN$, AN$, P, PY, L$
END IF
WEND
CLOSE #1
CLOSE #2
END
Original file is BOOK.TXT. All records with language as ENGLISH will be copied to new file ENG.TXT.
WRITE #2, BN$, AN$, P, PY, L$ will copy into #2, which mean ENG.TXT file.
OPEN "ENG.TXT" FOR OUTPUT AS #2
CLS
WHILE NOT EOF(1)
INPUT #1, BN$, AN$, P, PY, L$
IF UCASE$(L$)="ENGLISH" THEN
WRITE #2, BN$, AN$, P, PY, L$
END IF
WEND
CLOSE #1
CLOSE #2
END
Original file is BOOK.TXT. All records with language as ENGLISH will be copied to new file ENG.TXT.
WRITE #2, BN$, AN$, P, PY, L$ will copy into #2, which mean ENG.TXT file.