You are on page 1of 113

Project Work

Vehicle Management System

Group members:
Abhyudaya Man Singh
Rikesh Gautam
Pranay Govinda Amatya

Submitted to: Mr. Ibran


Ansari Sir
CERTIFICATE

This is to certify that content of this project entitled, “Vehicle Management System” is the bona

fide work submitted to the Department of Computer Science, Graded English Medium School

(GEMS) for consideration in partial fulfillment of the requirement of SEE, Nepal for the award

of a School Certificate.

The Original research work was carried out under my supervision in the academic year 2079.

Based on the declaration made by him/her/team, I recommend this project report for evaluation.

Remark: …………………………………………………………...................................................

Submission By: Certified By:

Abhyudaya Man Singh IBRAN ANSARI

Rikesh Gautam

Pranay Govinda Amatya

2
Contents
Acknowledgment...........................................................................................................................1
Introduction................................................................................................................................... 2
Analysis.......................................................................................................................................... 3
Algorithm....................................................................................................................................... 4
Flowchart..................................................................................................................................... 14
Coding.......................................................................................................................................... 27
Output......................................................................................................................................... 97
Conclusion................................................................................................................................. 110

3
Acknowledgment

We would like to acknowledge and give our warmest thanks to our teacher Mr. Ibran

Ansari Sir who allowed us to carry out this project work. His guidance and advice helped us plan

and write our project. We also got to learn about various new commands thanks to him.

We would also like to thank our group members for working hard and completing the

project work on time. We would also like to thank them for helping us with different problems

by providing suggestions and advice.

We would also like to thank our parents for their continuous support and for providing

us with the required resources to work on this project.

1
Introduction

The topic of the project work is “Vehicle Management System”. This program is based

on the menu-based program which can add, display, edit, search, delete and buy records. This

program shows the Name, Model, Company, Stock, and Price of the Vehicles. This program has

allowed us to flourish our knowledge in QBASIC and has given us completely new and useful

ideas in QBASIC. We have learned many other commands and statements that helped us

improve the skill and experience of the way of learning QBASIC

A data file that consists of data can be created in QBASIC to store data entered by the

user. According to the wish of the user, data can be added to the data file, and data from the

file can be displayed, edited, searched, or bought.

2
Analysis

Vehicle Management System is very important and applicable in real life. Along with

other sectors, computers have also entered the sector of buying and selling vehicles. So, Vehicle

Management Systems are used as they are easier, more accurate, and more reliant than

humans. Such a system is advantageous as:

1) It helps to reduce manual work

2) Searching and managing data can be done easily

3) It helps to store records of sales for a long time

4) To reduce manual errors

5) To debug the program easily

6) To know the vehicles which are relevant based on sales

3
Algorithm

ADDING RECORDS

step 1: if variable num is not 0 then open "Veh.dat" file for input

step 2: while it is not end of file, read the following variables: sn,n$,m$,c$,s,p and assign value

of sn to num

step 3: num = num + 1

step 4: close the program

step 5: open "Veh.dat" file for append

step 6: input the vehicle name,model,company,stock and price

step 7: write sn,n$,m$,c$,s,p in the file

step 8: value of num = num+1

step 9: ask user if they want to continue and store in ch$

step 10: if ch$="y" then go to step 6 else go to step 11

step 11: close the file

DISPLAYING RECORDS

step 1: ask the user which page he wanna go (1/2)

4
step 2: if page = 1 then go to step 3, if page = 2 then go to step 8 else print invalid and go to

step 1

step 3: open "Veh.dat" for input

step 4: assign the value of r=7

step 5: print the headers, read the data and print them in different positions

step 6: increase value of r by 2.9 and n by 1

step 7: close the file and end program

step 8: open "Veh.dat" for input

step 9: assign value of r as 7

step 10: print the headers

step 11: read the data and print them in different positions if n is greater than 8

step 12: increase value of r by 2.9 and n by 1

step 13: if it is not end of file go to step 11 else go to step 14

step 14: close the file and end program

SEARCHING RECORDS

SEARCH BY SYMBOL NUMBER

5
step 1: ask the symbol number to search (nsn)

step 2: open "Veh.dat" for input

step 3: keep the value r=7

step 4: print the headers

step 5: read the data

step 6: if nsn=sn then go to step 7

step 7: print sn,name$,model$,company$,stock,price using locate statement

step 8: keep the value of r=r+2.9 and f=f+1

step 9: if it is not end of file go to step 5 else go to step 9

step 10: close the file

step 11: if f=0 print "record not available"

SEARCH BY VEHICLE NAME

step 1: ask the vehicle name to search (nname$)

step 2: open "Veh.dat" for input

step 3: keep the value r=7

step 4: print the headers

6
step 5: read the data

step 6: if lcase$(nname$)=lcase$(name$) then go to step 7

step 7: print sn,name$,model$,company$,stock,price using locate statement

step 8: keep the value of r=r+2.9 and f=f+1

step 9: if it is not end of file go to step 5 else go to step 9

step 10: close the file

step 11: if f=0 print "record not available"

SEARCH BY MODEL

step 1: ask the vehicle model to search (nmodel$)

step 2: open "Veh.dat" for input

step 3: keep the value r=7

step 4: print the headers

step 5: read the data

step 6: if lcase$(nmodel$)=lcase$(model$) then go to step 7

step 7: print sn,name$,model$,company$,stock,price using locate statement

step 8: keep the value of r=r+2.9 and f=f+1

7
step 9: if it is not end of file go to step 5 else go to step 9

step 10: close the file

step 11: if f=0 print "record not available"

SEARCH BY COMPANY

step 1: ask the vehicle company to search (ncompany$)

step 2: open "Veh.dat" for input

step 3: keep the value r=7

step 4: print the headers

step 5: read the data

step 6: if lcase$(ncompany$)=lcase$(company$) then go to step 7

step 7: print sn,name$,model$,company$,stock,price using locate statement

step 8: keep the value of r=r+2.9 and f=f+1

step 9: if it is not end of file go to step 5 else go to step 9

step 10: close the file

step 11: if f=0 print "record not available"

8
SEARCH BY PRICE

step 1: ask for lower price (nlp) and upper price(nup)

step 2: open "Veh.dat" for input

step 3: keep the value of r=7

step 4: print the headers

step 5: read the data

step 6: if nlp<=price and nup>= price then go to step 7

step 7: print sn,name$,model$,company$,stock,price using locate statement

step 8: keeping the value r = r + 2.9,f = f + 1

step 9: if it is not end of file go to step 5 else go to step 9

step 10: close the file

step 11: if f=0 print "record not available"

BUYING

step 1: name for goto (buy2)

step 2: ask user to enter the s.n of the vehicle they want to buy (bsn)

step 3: open "Veh.dat" for input as 15

9
step 4: open "temp.dat" for output as 16

step 5: Read the data of input file

step 6: if bsn = sn then go to step 7

step 7: print vehicle name(name$),vehicle model(model$),vehicle company(company$),vehicle

price(price)

step 8: value of f=f+1

step 9: if stock <=0 then goto step 10 else go to step 11

step 10: print "sorry,out of stock"

step 11: print "confirm purchase(y/n)"(c$)

step 12: if c$=y then go to step 13 else go to buy2

step 13: print "purchase confirmed"

step 14: value of stock=stock-1

step 15: WRITE sn, name$, model$, company$, stock, price in ouput file

step 16: if it is not end of file go to step 5 else go to step 17

step 17: close both files

step 18: kill the file (Veh.dat)

step 19: name the file "temp.dat" as "Veh.dat"

10
step 20: if f=0 then go to step 21

step 21: print "record not available"

EDITING

step 1: open "Veh.dat" for input as 10

step 2: open "temp.dat" for output as 11

step 3: "ask the s.n of vehicle to edit (esn)"

step 4: Read the data of input file

step 5: if esn=sn then go to step 6 else WRITE (11) sn, name$, model$, company$, stock, price

step 6: the value of f=f+1

step 7: input vehicle name(nname$),vehicle

model(nmodel$),company(ncompany$),stock(nstock),price(price)

step 8: WRITE (11) sn, nname$, nmodel$, ncompany$, nstock, nprice

step 9: if it is not end of file go to step 4 else go to step 10

step 10: close both files

step 11: kill the file "Veh.dat"

step 12: name "temp.dat" as "Veh.dat"

11
step 13: if f=0 then go to step 14 else print "records edited"

step 14: print "record not available"

DELETING

step 1: Value of d$="deleted"

step 2: open "Veh.dat: for input as 20

step 3: open "temp.dat" for output as 21

step 4: ask the s.n of the vehicle record to be deleted (dsn)

step 5: Read the data of input file

step 6: if dsn<>sn then go to step 7 else WRITE (21), sn, d$, d$, d$, d$, 0

step 7: WRITE (21), sn, name$, model$, company$, stock, price

step 8: The value of f=f+1

step 9: if it is not end of file go to step 5 else go to step 10

step 10: close the files

step 11: kill the file "Veh.dat"

12
step 12: name the file "temp.dat" as "Veh.dat"

step 13: if f=0 then go to step 14 else print "record deleted"

step 14: print "record not found"

13
Flowchart

14
A

Ask user
what they
want to do

If add
record
B
If display
record
C

If edit
record

If delete
record

E
if search
record

F
if buy
vehicle

If quit
End

Else
Print
Invalid

15
B

Is num
<>0

Yes No

Open “Veh.dat” Open "Veh.dat"


for input for append

Input name$,
Is it the model$,
end of file company$,
stock and price

Write the
Yes No
values in
Veh.dat

Read all num = num +


Close the file values 1

num = num +
num = sn Ask user if
1
they want to
add more
records
B

No Yes

Close the File

A
16
C

What page
to go to

1 2

Open “Veh.dat” Open “Veh.dat”


for input for input

r = 7, n = 0 r = 7, n = 0

Print the Print the


headings headings

Is it end of
Is it end of
file and n is
file and n is
not less than
less than 8
8

Yes No Yes No

Read the Read the


Close the File values and Close the File values and
Print the Print the
values using values using
locate locate
A A
n = n +1, r = r + n = n +1, r = r +
2.9 2.9

17
D

Open "Veh.dat"
for input

Open "temp.dat"
for output

SN of
record to
edit (nsn)

Is it end
of file

Yes No

Read the
Close both files data from
"Veh.dat"

Delete "Veh.dat" Is esn =


sn

Remane Yes No
"temp.dat" as
"Veh.dat"
Write previous
f = f+ 1 data in
Is f = 0 "temp.dat"

Take new data


from user and
yes no write in
"temp.dat"
18
Print
"Record not A
available"
E
Open
"Veh.dat" for
input

Open
"temp.dat" for
output

SN of
record to
delete
(dsn)
Is it
end of
file

Yes No

Read the
Close both files data
from
"Veh.dat"
Delete
"Veh.dat"
Is esn
<> sn

Remane
"temp.dat" as
"Veh.dat" Yes No

Is f = 0 Write previous Write


data in "Deleted" in
"temp.dat" the file
yes no

Print
Print f = f+ 1
"Record
"Record
deleted
not
"
available"

A
19
F

Ask user by what


they want to
search

SN H

Name I

Model J

Company K

L
Price

Print
Else
Invalid
20
H

Ask user SN
they want
to search
(nsn)

Open "Veh.dat"
for input

Print the
Headings

Is it end
of file

Yes No

Read the
Close the file data

Is nsn =
Is f 0?
sn

Yes No Yes No

Print
Print the
Record
records
not
found
r=r+2.9, f = f +
A
1a

21
I

Ask user
Name they
want to
search
(nname$)

Open "Veh.dat"
for input

Print the
Headings

Is it end
of file

Yes No

Read the
Close the file data

Is
Is f 0? nname$
= name$

Yes No Yes No

Print
Print the
Record not
records
found

22

A r=r+2.9, f = f + 1a
J

Ask user
Model they
want to
search
(nmodel$)

Open "Veh.dat"
for input

Print the
Headings

Is it end
of file

Yes No

Read the
Close the file data

Is
Is f 0? nmodel$
=
model$

Yes No Yes No

Print
Print the
Record
records
not found

23

A r=r+2.9, f = f + 1a
K

Ask user
Company they
want to
search
(ncompany$)

Open "Veh.dat" for


input

Print the
Headings

Is it end
of file

Yes No

Read the
Close the file data

Is
Is f 0? ncompan
y$ =
company
$
Yes No

Yes No
Print
Record
not found
Print the
records

24

A r=r+2.9, f = f + 1a
L

Ask user
upper and
lower price
limit (nup,
nlp)

Open "Veh.dat"
for input

Print the
Headings

Is it end
of file

Yes No

Read the
Close the file data

Is f 0? Is nlp <=
price AND
nup >= price

Yes No
Yes No

Print
Record
not found Print the
records

25
A
r=r+2.9, f = f + 1a
G

Ask user
the vehicle
to buy (bsn)

Open "Veh.dat"
for input

Open "temp.dat"
for ouput

Is it end
of file

Yes No

Read
the
data
Close both files
Is bsn
= sn
Yes No
Delete "Veh.dat"
Print
the data

Rename f=f+1
"temp.dat" as
"Veh.dat" Is
stock =
0
Is f =
0
Yes No
Write the
Print Confirm values in
Yes No Sorry, out "temp."
purchas
of stock e (y/n)
Print G
A
"Record Yes No
not
availabl Print
e" G
purchase
26 confirmed
stock =
stock -1
Coding

COMMON SHARED t$, tlen, mid, quitask, num

declare sub welcome()

declare sub home()

declare sub admin()

declare sub customer()

declare sub addVeh() 'sn, name$, model$, company$, stock, price

declare sub display()

declare sub search(user$)

declare sub searchsn()

declare sub searchvn()

declare sub searchm()

declare sub searchc()

declare sub searchp()

declare sub delete()

declare sub edit()

declare sub buy()

27
declare function load()

declare function gobackask()

CLS

CALL welcome

CALL home

SUB home ()

CLS

SCREEN 12

COLOR 10

t$ = "Vehicle Management Record Keeping System"

tlen = LEN(t$)

mid = (78 - tlen) / 2

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

28
NEXT k

PRINT

LOCATE 5: PRINT "What are you?(1/2)"

LOCATE 6: PRINT "1. ADMIN"

LOCATE 7: PRINT "2. CUSTOMER"

choose:

DO

k$ = INKEY$

LOOP UNTIL k$ <> ""

SELECT CASE k$

CASE "1"

LOCATE 6: PRINT "> "

PRINT "x "

SLEEP 1

PRINT load

pass:

CLS

29
LOCATE 1, mid

PRINT t$

LOCATE 10, 20

PRINT "Password: "

LINE (235, 135)-(400, 165), , B

LOCATE 10, 31

INPUT "", p$

IF p$ = "iamadmin" THEN

CALL admin

ELSE

CLS

LOCATE 1, mid

PRINT t$

LOCATE 11, (78 - LEN("Incorrect Password")) / 2

PRINT "Incorrect Password"

SLEEP 1

a=a+1

30
IF a = 5 THEN

LOCATE 12, (78 - LEN("Incorrect 5 times")) / 2: PRINT "Incorrect 5 times": LOCATE 13,

(78 - LEN("Press any key to return home")) / 2: PRINT "Press any key to return home"

SLEEP

CLS

CALL home

ELSE

GOTO pass

END IF

END IF

CASE "2"

LOCATE 6: PRINT "x "

PRINT "> "

SLEEP 1

PRINT load

CALL customer

CASE ELSE

31
GOTO choose

END SELECT

END SUB

SUB admin ()

admin2:

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

PRINT "What do you want to do?"

LOCATE 7: PRINT "1. Add Vehicles Records"

PRINT "2. Display Vehicles Records"

32
PRINT "3. Search Vehicles Records"

PRINT "4. Edit Vehicles Records"

PRINT "5. Delete Vehicles Records"

PRINT "6. Quit"

choose:

DO

k$ = INKEY$

LOOP UNTIL k$ <> ""

SELECT CASE k$

CASE "1"

LOCATE 7, 1: PRINT "> "

PRINT "x "

PRINT "x "

PRINT "x "

PRINT "x "

PRINT "x "

SLEEP 1

33
CALL addVeh

GOTO admin2

CASE "2"

LOCATE 7, 1: PRINT "x "

PRINT "> "

PRINT "x "

PRINT "x "

PRINT "x "

PRINT "x "

SLEEP 1

CALL display

GOTO admin2

CASE "3"

LOCATE 7, 1: PRINT "x "

PRINT "x "

PRINT "> "

PRINT "x "

34
PRINT "x "

PRINT "x "

SLEEP 1

CALL search("admin")

CASE "4"

LOCATE 7, 1: PRINT "x "

PRINT "x "

PRINT "x "

PRINT "> "

PRINT "x "

PRINT "x"

SLEEP 1

CALL edit

GOTO admin2

CASE "5"

LOCATE 7, 1: PRINT "x "

PRINT "x "

35
PRINT "x "

PRINT "x "

PRINT "> "

PRINT "x "

SLEEP 1

CALL delete

GOTO admin2

CASE "6"

LOCATE 7, 1: PRINT "x "

PRINT "x "

PRINT "x "

PRINT "x "

PRINT "x "

PRINT "> "

SLEEP 1

PRINT gobackask

IF quitask = 1 THEN

36
CLS

LOCATE 1, mid

PRINT t$

LOCATE 13, (78 - LEN("Thanks For Using This Program!")) / 2: PRINT "Thanks For Using

This Program!"

WHILE i <= 8

IF i MOD 2 = 0 THEN

COLOR 11

ELSE

COLOR 9

END IF

FOR k = 1 TO 30

LOCATE 8, 8 + 2 * k: PRINT "[]";

NEXT k

FOR k = 8 TO 19

LOCATE k, 8: PRINT "[]";

LOCATE k, 70: PRINT "[]"

37
NEXT k

FOR k = 1 TO 30

LOCATE 19, 8 + 2 * k: PRINT "[]";

NEXT k

i=i+1

SLEEP 1

WEND

ELSEIF quitask = 0 THEN

GOTO admin2

END IF

CASE ELSE

GOTO choose

END SELECT

END SUB

SUB customer ()

customer2:

CLS

38
LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

PRINT "What do you want to do?"

LOCATE 7: PRINT "1. Display Vehicles Records"

PRINT "2. Search Vehicles Records"

PRINT "3. Buy Vehicles Records"

PRINT "4. Quit"

choose:

DO

k$ = INKEY$

LOOP UNTIL k$ <> ""

39
SELECT CASE k$

CASE "1"

LOCATE 7, 1: PRINT "> "

PRINT "x "

PRINT "x "

PRINT "x "

SLEEP 1

CALL display

GOTO customer2

CASE "2"

LOCATE 7, 1: PRINT "x "

PRINT "> "

PRINT "x "

PRINT "x "

SLEEP 1

CALL search("customer")

CASE "3"

40
LOCATE 7, 1: PRINT "x "

PRINT "x "

PRINT "> "

PRINT "x "

SLEEP 1

CALL buy

GOTO customer2

CASE "4"

LOCATE 7, 1: PRINT "x "

PRINT "x "

PRINT "x "

PRINT "> "

SLEEP 1

PRINT gobackask

IF quitask = 1 THEN

CLS

LOCATE 1, mid

41
PRINT t$

LOCATE 13, (78 - LEN("Thanks For Using This Program!")) / 2: PRINT "Thanks For Using

This Program!"

WHILE i <= 8

IF i MOD 2 = 0 THEN

COLOR 11

ELSE

COLOR 9

END IF

FOR k = 1 TO 30

LOCATE 8, 8 + 2 * k: PRINT "[]";

NEXT k

FOR k = 8 TO 19

LOCATE k, 8: PRINT "[]";

LOCATE k, 70: PRINT "[]"

NEXT k

FOR k = 1 TO 30

42
LOCATE 19, 8 + 2 * k: PRINT "[]";

NEXT k

i=i+1

SLEEP 1

WEND

ELSEIF quitask = 0 THEN

GOTO customer2

END IF

CASE ELSE

GOTO choose

END SELECT

END SUB

SUB addVeh ()

IF num <> 0 THEN

OPEN "Veh.dat" FOR INPUT AS #100

WHILE NOT EOF(100)

INPUT #100, sn, n$, m$, c$, s, p

43
num = sn

WEND

CLOSE #100

num = num + 1

END IF

OPEN "Veh.dat" FOR APPEND AS #1

c=0

DO

c=c+1

CLS

LOCATE 1, mid

PRINT t$

LOCATE 2, (78 - LEN("Add Vehicle Records")) / 2: PRINT "Add Vehicle Records"

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

44
INPUT "Vehicle Name: ", name$

INPUT "Vehicle Model: ", model$

INPUT "Vehicle Company: ", company$

INPUT "Vehicle Stock: ", stock

INPUT "Vehicle Price($): ", price

WRITE #1, num, LTRIM$(RTRIM$(name$)), LTRIM$(RTRIM$(model$)), LTRIM$(RTRIM$

(company$)), stock, price

INPUT "Enter another record"; ch$

num = num + 1

LOOP WHILE LCASE$(ch$) = "y"

CLOSE #1

CLS

LOCATE 1, mid

PRINT t$

LOCATE 2, (78 - LEN("Add Vehicle Records")) / 2: PRINT "Add Vehicle Records"

PRINT

45
IF c = 1 THEN

LOCATE 4, (78 - LEN("Record Added!")) / 2: PRINT "Record Added!"

ELSE

LOCATE 4, (78 - LEN("Records Added!")) / 2: PRINT "Records Added!"

END IF

SLEEP 2

END SUB

SUB display ()

ask:

CLS

LOCATE 1, mid

PRINT t$

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT "Which page(1/2)?"

46
INPUT "", page

PRINT load

IF page = 1 THEN

CLS

OPEN "Veh.dat" FOR INPUT AS #2

r=7

n=0

LOCATE 1, mid

PRINT t$

LOCATE 2, (78 - LEN("All Vehicle Records(1/2)")) / 2: PRINT "All Vehicle Records(1/2)"

LINE (20, 50)-(615, 90), , B

LINE (20, 90)-(615, 135), , B

LINE (20, 90)-(615, 180), , B

LINE (20, 90)-(615, 225), , B

LINE (20, 90)-(615, 270), , B

LINE (20, 90)-(615, 315), , B

LINE (20, 90)-(615, 360), , B

47
LINE (20, 90)-(615, 405), , B

LINE (20, 90)-(615, 450), , B

LINE (20, 50)-(60, 450), , B

LOCATE 5, 5

PRINT "SN"

LINE (60, 50)-(150, 450), , B

LOCATE 5, 12

PRINT "Name"

LINE (150, 50)-(275, 450), , B

LOCATE 5, 25

PRINT "Model"

LINE (275, 50)-(400, 450), , B

LOCATE 5, 40

PRINT "Company"

LINE (400, 50)-(507.5, 450), , B

LOCATE 5, 55

PRINT "Stock"

48
LINE (507.5, 50)-(615, 450), , B

LOCATE 5, 69

PRINT "Price$"

WHILE NOT EOF(2) AND n < 8

INPUT #2, sn, name$, model$, company$, stock, price

LOCATE r, 4

PRINT sn

IF LEN(name$) > 9 THEN

LOCATE r, 10

PRINT LEFT$(name$, 9)

LOCATE r + 1, 10

PRINT "-" + RIGHT$(name$, LEN(name$) - 9)

ELSE

LOCATE r, 10

PRINT name$

END IF

IF LEN(model$) > 14 THEN

49
LOCATE r, 21

PRINT LEFT$(model$, 14)

IF LEN(model$) > 24 THEN

LOCATE r + 1, 21

PRINT "-" + MID$(model$, LEN(model$) - 16, 10) + "..."

ELSE

LOCATE r + 1, 21

PRINT "-" + RIGHT$(model$, LEN(model$) - 14)

END IF

ELSE

LOCATE r, 21

PRINT model$

END IF

IF LEN(company$) > 15 THEN

LOCATE r, 36

PRINT LEFT$(company$, 15)

LOCATE r + 1, 36

50
PRINT "-" + RIGHT$(company$, LEN(company$) - 15)

ELSE

LOCATE r, 36

PRINT company$

END IF

LOCATE r, 55

PRINT stock

LOCATE r, 67

PRINT price

r = r + 2.9

n=n+1

WEND

CLOSE #2

ELSEIF page = 2 THEN

CLS

OPEN "Veh.dat" FOR INPUT AS #2

r=7

51
LOCATE 1, mid

PRINT t$

LOCATE 2, (78 - LEN("All Vehicle Records(2/2)")) / 2: PRINT "All Vehicle Records(2/2)"

LINE (20, 50)-(615, 90), , B

LINE (20, 90)-(615, 135), , B

LINE (20, 90)-(615, 180), , B

LINE (20, 90)-(615, 225), , B

LINE (20, 90)-(615, 270), , B

LINE (20, 90)-(615, 315), , B

LINE (20, 90)-(615, 360), , B

LINE (20, 90)-(615, 405), , B

LINE (20, 90)-(615, 450), , B

LINE (20, 50)-(60, 450), , B

LOCATE 5, 5

PRINT "SN"

LINE (60, 50)-(150, 450), , B

LOCATE 5, 12

52
PRINT "Name"

LINE (150, 50)-(275, 450), , B

LOCATE 5, 25

PRINT "Model"

LINE (275, 50)-(400, 450), , B

LOCATE 5, 40

PRINT "Company"

LINE (400, 50)-(507.5, 450), , B

LOCATE 5, 55

PRINT "Stock"

LINE (507.5, 50)-(615, 450), , B

LOCATE 5, 69

PRINT "Price$"

WHILE NOT EOF(2)

INPUT #2, sn, name$, model$, company$, stock, price

IF sn > 8 THEN

LOCATE r, 4

53
PRINT sn

IF LEN(name$) > 9 THEN

LOCATE r, 10

PRINT LEFT$(name$, 9)

LOCATE r + 1, 10

PRINT "-" + RIGHT$(name$, LEN(name$) - 9)

ELSE

LOCATE r, 10

PRINT name$

END IF

IF LEN(model$) > 14 THEN

LOCATE r, 21

PRINT LEFT$(model$, 14)

IF LEN(model$) > 24 THEN

LOCATE r + 1, 21

PRINT "-" + MID$(model$, LEN(model$) - 16, 10) + "..."

ELSE

54
LOCATE r + 1, 21

PRINT "-" + RIGHT$(model$, LEN(model$) - 14)

END IF

ELSE

LOCATE r, 21

PRINT model$

END IF

IF LEN(company$) > 15 THEN

LOCATE r, 36

PRINT LEFT$(company$, 15)

LOCATE r + 1, 36

PRINT "-" + RIGHT$(company$, LEN(company$) - 15)

ELSE

LOCATE r, 36

PRINT company$

END IF

LOCATE r, 55

55
PRINT stock

LOCATE r, 67

PRINT price

c=c+1

r = r + 2.9

n=n+1

END IF

WEND

CLOSE #2

ELSE

PRINT "Invalid"

SLEEP 1

GOTO ask

END IF

SLEEP

CLS

LOCATE 1, mid

56
PRINT t$

COLOR 0

INPUT "", n$

COLOR 10

INPUT "View another pg(y/n)"; ch$

IF LCASE$(ch$) = "y" THEN GOTO ask:

END SUB

SUB search (user$)

search2:

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

57
PRINT

PRINT "Search by..."

PRINT "1. SN"

PRINT "2. Vehicle Name"

PRINT "3. Model"

PRINT "4. Company"

PRINT "5. Price$"

PRINT

PRINT "Go Back(b)"

ask:

DO

k$ = INKEY$

LOOP UNTIL k$ <> ""

SELECT CASE k$

CASE "1"

LOCATE 6: PRINT "> "

PRINT "x "

58
PRINT "x "

PRINT "x "

PRINT "x "

SLEEP 1

CALL searchsn

GOTO search2

CASE "2"

LOCATE 6: PRINT "x "

PRINT "> "

PRINT "x "

PRINT "x "

PRINT "x "

SLEEP 1

CALL searchvn

GOTO search2

CASE "3"

LOCATE 6: PRINT "x "

59
PRINT "x "

PRINT "> "

PRINT "x "

PRINT "x "

SLEEP 1

CALL searchm

GOTO search2

CASE "4"

LOCATE 6: PRINT "x "

PRINT "x "

PRINT "x "

PRINT "> "

PRINT "x "

SLEEP 1

CALL searchc

GOTO search2

CASE "5"

60
LOCATE 6: PRINT "x "

PRINT "x "

PRINT "x "

PRINT "x "

PRINT "> "

SLEEP 1

CALL searchp

GOTO search2

CASE "b"

LOCATE 6: PRINT "x "

PRINT "x "

PRINT "x "

PRINT "x "

PRINT "x "

SLEEP 1

IF LCASE$(user$) = "admin" THEN

CALL admin

61
ELSEIF LCASE$(user$) = "customer" THEN

CALL customer

ELSE

CALL home

END IF

CASE ELSE

GOTO ask

END SELECT

END SUB

SUB edit ()

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

62
PRINT

PRINT

OPEN "Veh.dat" FOR INPUT AS #10

OPEN "temp.dat" FOR OUTPUT AS #11

INPUT "Edit record (S.N.): ", esn

WHILE NOT EOF(10)

INPUT #10, sn, name$, model$, company$, stock, price

IF esn = sn THEN

f=f+1

PRINT

INPUT "Vehicle Name: ", nname$

INPUT "Vehicle Model: ", nmodel$

INPUT "Vehicle Company: ", ncompany$

INPUT "Vehicle Stock: ", nstock

INPUT "Vehicle Price($): ", nprice

WRITE #11, sn, LTRIM$(RTRIM$(nname$)), LTRIM$(RTRIM$(nmodel$)), LTRIM$(RTRIM$

(ncompany$)), nstock, nprice

63
ELSE

WRITE #11, sn, name$, model$, company$, stock, price

END IF

WEND

CLOSE #10, #11

KILL "Veh.dat"

NAME "temp.dat" AS "Veh.dat"

IF f = 0 THEN

LOCATE CSRLIN + 2, (78 - LEN("Record Not Found")) / 2: PRINT "Record Not Found"

SLEEP 1

ELSE

LOCATE CSRLIN + 2, (78 - LEN("Record Edited")) / 2: PRINT "Record Edited"

SLEEP 1

END IF

END SUB

SUB delete ()

d$ = "Deleted"

64
CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

OPEN "Veh.dat" FOR INPUT AS #20

OPEN "temp.dat" FOR OUTPUT AS #21

INPUT "Delete record (S.N.): ", dsn

WHILE NOT EOF(20)

INPUT #20, sn, name$, model$, company$, stock, price

IF dsn <> sn THEN

WRITE #21, sn, name$, model$, company$, stock, price

ELSE

65
f=f+1

WRITE #21, sn, d$, d$, d$, d$, d$

END IF

WEND

CLOSE #20, #21

KILL "Veh.dat"

NAME "temp.dat" AS "Veh.dat"

IF f = 0 THEN

LOCATE CSRLIN + 2, (78 - LEN("Record Not Found")) / 2: PRINT "Record Not Found"

SLEEP 1

ELSE

LOCATE CSRLIN + 2, (78 - LEN("Record Deleted")) / 2: PRINT "Record Deleted"

SLEEP 1

END IF

END SUB

SUB searchsn ()

CLS

66
LOCATE 1, mid

PRINT t$

PRINT

PRINT "Vehicle S.N. to search: ";

INPUT "", nsn

PRINT load

CLS

OPEN "Veh.dat" FOR INPUT AS #3

r=7

n=0

LOCATE 1, mid

PRINT t$

LINE (20, 50)-(615, 90), , B

LINE (20, 90)-(615, 135), , B

LINE (20, 90)-(615, 180), , B

LINE (20, 90)-(615, 225), , B

LINE (20, 90)-(615, 270), , B

67
LINE (20, 90)-(615, 315), , B

LINE (20, 90)-(615, 360), , B

LINE (20, 90)-(615, 405), , B

LINE (20, 90)-(615, 450), , B

LINE (20, 50)-(60, 450), , B

LOCATE 5, 5

PRINT "SN"

LINE (60, 50)-(150, 450), , B

LOCATE 5, 12

PRINT "Name"

LINE (150, 50)-(275, 450), , B

LOCATE 5, 25

PRINT "Model"

LINE (275, 50)-(400, 450), , B

LOCATE 5, 40

PRINT "Company"

LINE (400, 50)-(507.5, 450), , B

68
LOCATE 5, 55

PRINT "Stock"

LINE (507.5, 50)-(615, 450), , B

LOCATE 5, 69

PRINT "Price$"

WHILE NOT EOF(3)

INPUT #3, sn, name$, model$, company$, stock, price

IF nsn = sn THEN

LOCATE r, 4: PRINT sn

LOCATE r, 10: PRINT name$

LOCATE r, 21: PRINT model$

LOCATE r, 36: PRINT company$

LOCATE r, 55: PRINT stock

LOCATE r, 67: PRINT price

r = r + 2.9

f=f+1

END IF

69
WEND

CLOSE #3

IF f = 0 THEN

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

LOCATE CSRLIN, 29: PRINT "Record Not Available"

END IF

SLEEP

END SUB

SUB searchvn ()

70
CLS

LOCATE 1, mid

PRINT t$

PRINT

PRINT "Vehicle Name to search: ";

INPUT "", nname$

PRINT load

CLS

OPEN "Veh.dat" FOR INPUT AS #4

r=7

n=0

LOCATE 1, mid

PRINT t$

LINE (20, 50)-(615, 90), , B

LINE (20, 90)-(615, 135), , B

LINE (20, 90)-(615, 180), , B

LINE (20, 90)-(615, 225), , B

71
LINE (20, 90)-(615, 270), , B

LINE (20, 90)-(615, 315), , B

LINE (20, 90)-(615, 360), , B

LINE (20, 90)-(615, 405), , B

LINE (20, 90)-(615, 450), , B

LINE (20, 50)-(60, 450), , B

LOCATE 5, 5

PRINT "SN"

LINE (60, 50)-(150, 450), , B

LOCATE 5, 12

PRINT "Name"

LINE (150, 50)-(275, 450), , B

LOCATE 5, 25

PRINT "Model"

LINE (275, 50)-(400, 450), , B

LOCATE 5, 40

PRINT "Company"

72
LINE (400, 50)-(507.5, 450), , B

LOCATE 5, 55

PRINT "Stock"

LINE (507.5, 50)-(615, 450), , B

LOCATE 5, 69

PRINT "Price$"

WHILE NOT EOF(4)

INPUT #4, sn, name$, model$, company$, stock, price

IF LCASE$(nname$) = LCASE$(name$) THEN

LOCATE r, 4: PRINT sn

LOCATE r, 10: PRINT name$

LOCATE r, 21: PRINT model$

LOCATE r, 36: PRINT company$

LOCATE r, 55: PRINT stock

LOCATE r, 67: PRINT price

r = r + 2.9

f=f+1

73
END IF

WEND

CLOSE #4

IF f = 0 THEN

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

LOCATE CSRLIN, 29: PRINT "Record Not Available"

END IF

SLEEP

END SUB

74
SUB searchm ()

CLS

LOCATE 1, mid

PRINT t$

PRINT

PRINT "Vehicle Model to search: ";

INPUT "", nmodel$

PRINT load

CLS

OPEN "Veh.dat" FOR INPUT AS #5

r=7

n=0

LOCATE 1, mid

PRINT t$

LINE (20, 50)-(615, 90), , B

LINE (20, 90)-(615, 135), , B

LINE (20, 90)-(615, 180), , B

75
LINE (20, 90)-(615, 225), , B

LINE (20, 90)-(615, 270), , B

LINE (20, 90)-(615, 315), , B

LINE (20, 90)-(615, 360), , B

LINE (20, 90)-(615, 405), , B

LINE (20, 90)-(615, 450), , B

LINE (20, 50)-(60, 450), , B

LOCATE 5, 5

PRINT "SN"

LINE (60, 50)-(150, 450), , B

LOCATE 5, 12

PRINT "Name"

LINE (150, 50)-(275, 450), , B

LOCATE 5, 25

PRINT "Model"

LINE (275, 50)-(400, 450), , B

LOCATE 5, 40

76
PRINT "Company"

LINE (400, 50)-(507.5, 450), , B

LOCATE 5, 55

PRINT "Stock"

LINE (507.5, 50)-(615, 450), , B

LOCATE 5, 69

PRINT "Price$"

WHILE NOT EOF(5)

INPUT #5, sn, name$, model$, company$, stock, price

IF LCASE$(nmodel$) = LCASE$(model$) THEN

LOCATE r, 4: PRINT sn

LOCATE r, 10: PRINT name$

LOCATE r, 21: PRINT model$

LOCATE r, 36: PRINT company$

LOCATE r, 55: PRINT stock

LOCATE r, 67: PRINT price

r = r + 2.9

77
f=f+1

END IF

WEND

CLOSE #5

IF f = 0 THEN

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

LOCATE CSRLIN, 29: PRINT "Record Not Available"

END IF

SLEEP

78
END SUB

SUB searchc ()

CLS

LOCATE 1, mid

PRINT t$

PRINT

PRINT "Vehicle Company to search: ";

INPUT "", ncompany$

PRINT load

CLS

OPEN "Veh.dat" FOR INPUT AS #6

r=7

n=0

LOCATE 1, mid

PRINT t$

LINE (20, 50)-(615, 90), , B

LINE (20, 90)-(615, 135), , B

79
LINE (20, 90)-(615, 180), , B

LINE (20, 90)-(615, 225), , B

LINE (20, 90)-(615, 270), , B

LINE (20, 90)-(615, 315), , B

LINE (20, 90)-(615, 360), , B

LINE (20, 90)-(615, 405), , B

LINE (20, 90)-(615, 450), , B

LINE (20, 50)-(60, 450), , B

LOCATE 5, 5

PRINT "SN"

LINE (60, 50)-(150, 450), , B

LOCATE 5, 12

PRINT "Name"

LINE (150, 50)-(275, 450), , B

LOCATE 5, 25

PRINT "Model"

LINE (275, 50)-(400, 450), , B

80
LOCATE 5, 40

PRINT "Company"

LINE (400, 50)-(507.5, 450), , B

LOCATE 5, 55

PRINT "Stock"

LINE (507.5, 50)-(615, 450), , B

LOCATE 5, 69

PRINT "Price$"

WHILE NOT EOF(6)

INPUT #6, sn, name$, model$, company$, stock, price

IF LCASE$(ncompany$) = LCASE$(company$) THEN

LOCATE r, 4: PRINT sn

LOCATE r, 10: PRINT name$

LOCATE r, 21: PRINT model$

LOCATE r, 36: PRINT company$

LOCATE r, 55: PRINT stock

LOCATE r, 67: PRINT price

81
r = r + 2.9

f=f+1

END IF

WEND

CLOSE #6

IF f = 0 THEN

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

LOCATE CSRLIN, 29: PRINT "Record Not Available"

END IF

82
SLEEP

END SUB

SUB searchp ()

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

PRINT "Lower Price Limit: ";

INPUT "", nlp

PRINT "Upper Price Limit: ";

INPUT "", nup

PRINT load

83
CLS

OPEN "Veh.dat" FOR INPUT AS #7

r=7

n=0

LOCATE 1, mid

PRINT t$

LINE (20, 50)-(615, 90), , B

LINE (20, 90)-(615, 135), , B

LINE (20, 90)-(615, 180), , B

LINE (20, 90)-(615, 225), , B

LINE (20, 90)-(615, 270), , B

LINE (20, 90)-(615, 315), , B

LINE (20, 90)-(615, 360), , B

LINE (20, 90)-(615, 405), , B

LINE (20, 90)-(615, 450), , B

LINE (20, 50)-(60, 450), , B

LOCATE 5, 5

84
PRINT "SN"

LINE (60, 50)-(150, 450), , B

LOCATE 5, 12

PRINT "Name"

LINE (150, 50)-(275, 450), , B

LOCATE 5, 25

PRINT "Model"

LINE (275, 50)-(400, 450), , B

LOCATE 5, 40

PRINT "Company"

LINE (400, 50)-(507.5, 450), , B

LOCATE 5, 55

PRINT "Stock"

LINE (507.5, 50)-(615, 450), , B

LOCATE 5, 69

PRINT "Price$"

WHILE NOT EOF(7) AND n < 8

85
INPUT #7, sn, name$, model$, company$, stock, price

IF nlp <= price AND nup >= price THEN

LOCATE r, 4: PRINT sn

LOCATE r, 10: PRINT name$

LOCATE r, 21: PRINT model$

LOCATE r, 36: PRINT company$

LOCATE r, 55: PRINT stock

LOCATE r, 67: PRINT price

r = r + 2.9

f=f+1

n=n+1

END IF

WEND

CLOSE #7

IF f = 0 THEN

CLS

LOCATE 1, mid

86
PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

LOCATE CSRLIN, 29: PRINT "Record Not Available"

END IF

SLEEP

END SUB

SUB buy ()

buy2:

CLS

LOCATE 1, mid

PRINT t$

PRINT

87
FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

INPUT "Which Vehicle do you want to buy (S.N.)"; bsn

PRINT

OPEN "Veh.dat" FOR INPUT AS #15

OPEN "temp.dat" FOR OUTPUT AS #16

WHILE NOT EOF(15)

INPUT #15, sn, name$, model$, company$, stock, price

IF bsn = sn THEN

PRINT "Vehicle Name: "; name$

PRINT "Vehicle Model: "; model$

PRINT "Vehicle Company: "; company$

PRINT "Vehicle Price$: "; price

f=f+1

88
PRINT

IF stock <= 0 THEN

PRINT "Sorry, out of stock!"

ELSE

INPUT "Confirm Purchase (y/n)"; c$

IF LCASE$(c$) = "y" THEN

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

NEXT k

PRINT

PRINT

LOCATE 15, (78 - LEN("Purchase Confirmed")) / 2: PRINT "Purchase Confirmed"

stock = stock - 1

89
ELSE

GOTO buy2

END IF

END IF

END IF

WRITE #16, sn, name$, model$, company$, stock, price

WEND

CLOSE #15, #16

KILL "Veh.dat"

NAME "temp.dat" AS "Veh.dat"

IF f = 0 THEN

CLS

LOCATE 1, mid

PRINT t$

PRINT

FOR k = 1 TO 80

PRINT "=";

90
NEXT k

PRINT

PRINT

LOCATE CSRLIN, 29: PRINT "Record Not Available"

END IF

SLEEP

END SUB

SUB welcome ()

SCREEN 12

te$ = "Welcome to Vehicle Management System"

WHILE i <= 8

IF i MOD 2 = 0 THEN

COLOR 11

ELSE

COLOR 9

END IF

FOR k = 1 TO 30

91
LOCATE 8, 10 + 2 * k: PRINT "[]";

NEXT k

FOR k = 8 TO 19

LOCATE k, 10: PRINT "[]";

LOCATE k, 70: PRINT "[]"

NEXT k

FOR k = 1 TO 30

LOCATE 19, 10 + 2 * k: PRINT "[]";

NEXT k

IF i MOD 2 = 0 THEN

c = 14

COLOR 10

ELSE

c = 10

COLOR 14

END IF

LOCATE 13, (78 - LEN(te$)) / 2 + 2: PRINT te$

92
LINE (150, 175)-(400, 175), c

LINE (150, 175)-(150, 225), c

LINE (150, 225)-(175, 225), c

LINE (175, 225)-(175, 250), c

LINE (175, 250)-(200, 250), c

LINE (200, 250)-(200, 225), c

LINE (200, 225)-(212, 225), c

LINE (212, 225)-(212, 250), c

LINE (212, 250)-(237, 250), c

LINE (237, 250)-(237, 225), c

LINE (237, 225)-(400, 225), c

CIRCLE (450, 200), 55, c, 3.625, 2.65

SLEEP 1

i=i+1

WEND

END SUB

FUNCTION load ()

93
CLS

LOCATE 1, mid

PRINT t$

c=0

DO WHILE c <> 1

LOCATE 1, mid: PRINT t$

LOCATE 10, 36: PRINT ". "

SLEEP 1

CLS

LOCATE 1, mid: PRINT t$

LOCATE 10, 36: PRINT ".. "

SLEEP 1

CLS

LOCATE 1, mid: PRINT t$

LOCATE 10, 36: PRINT "... "

SLEEP 1

CLS

94
LOCATE 1, mid: PRINT t$

LOCATE 10, 36: PRINT ". "

SLEEP 1

CLS

LOCATE 1, mid: PRINT t$

LOCATE 10, 36: PRINT ".... "

SLEEP 1

CLS

LOCATE 1, mid: PRINT t$

LOCATE 10, 36: PRINT "....."

SLEEP 1

CLS

LOCATE 1, mid: PRINT t$

c=c+1

LOOP

END FUNCTION

FUNCTION gobackask ()

95
CLS

LOCATE 1, mid

PRINT t$

q:

q$ = "Are you sure you want to quit(y/n)?"

LOCATE 4, (78 - LEN(q$)) / 2: PRINT q$

LOCATE 5, 39

INPUT "", ch$

IF LCASE$(ch$) = "y" THEN

quitask = 1

ELSEIF LCASE$(ch$) = "n" THEN

quitask = 0

ELSE

a$ = "Invalid Input"

LOCATE 7, (78 - LEN(a$)) / 2: PRINT a$

GOTO q

END IF

96
END FUNCTION

Output

97
98
99
100
101
102
103
104
105
106
107
108
109
Conclusion
In this way, we were able to create a menu-driven program that can create a data file

and add records to it, search, edit and delete those records and it also has provision for the

customer to buy the records.

Through this project, we learned about various new statements and commands. We also

learned to solve different problems that arose during the development of the program. This has

helped us understand file handling and modular programming better as well.

We also learned the importance of teamwork and hard work through this project along

with programming.

So, we would like once again to thank our teacher, Mr. Ibran Ansari sir for providing us

with this opportunity.

110

You might also like