Hi all,
I am a new qbasic student
I am trying to run this transaction part of a cash register program, but when I run it the output is all zeros! can anyone tell me what I am doing wrong
any input will be appreciated
pdata: 'sample of inventory data
DATA 125, "nails", 1.25, 2.22, 1.69, "N", "Y", 1200
tdata:
DATA 1, 392, 1 'sample of my transaction data
TYPE product
x AS INTEGER
id AS INTEGER
nam AS STRING * 20
cost AS SINGLE
price AS SINGLE
sprice AS SINGLE
sale AS STRING * 1
tax AS STRING * 1
qty AS INTEGER
END TYPE
TYPE reciept
x AS INTEGER
id AS INTEGER
scode AS INTEGER
nam AS STRING * 20
qty AS INTEGER
price AS SINGLE
tcost AS SINGLE
END TYPE
DIM pr AS product
DIM bill AS reciept
DIM count AS INTEGER
count = 0
RESTORE pdata
FOR i = 1 TO 9 STEP 1 'here I loaded all product information in pr
READ id, nam$, cost, price, sprice, sale$, tax$, qty
NEXT
FOR i = 0 TO count STEP 1'outputs bill
PRINT bill.nam; (i); " "; bill.price; (i); " "; bill.qty; (i)
NEXT
PRINT bill.tcost
SLEEP 10 'this command just pauses the program for 10 seconds
END
SUB trans
RESTORE t1data
FOR j = 1 TO 22 STEP 1 'loading transaction info
READ scode, id, qty
FOR i = 1 TO 9 STEP 1
IF id = id THEN 'checking for id match
nam = nam 'copying name of product to bill
qty = qty - billqty 'updating qty of product
IF prsale$ = "Y" THEN 'checks if item is on sale
billprice = prsprice 'sets bill price to sale price if on sale
ELSE
billprice = prprice
END IF
IF prtax$ = "Y" THEN 'checks if there is tax
billprice = billprice * 1.15 'adjust price for tax (15%)
END IF
billtcost = billtcost + billqty * billprice 'update total cost
count = count + 1
END IF
NEXT
NEXT
END SUB
I am a new qbasic student
I am trying to run this transaction part of a cash register program, but when I run it the output is all zeros! can anyone tell me what I am doing wrong
any input will be appreciated
pdata: 'sample of inventory data
DATA 125, "nails", 1.25, 2.22, 1.69, "N", "Y", 1200
tdata:
DATA 1, 392, 1 'sample of my transaction data
TYPE product
x AS INTEGER
id AS INTEGER
nam AS STRING * 20
cost AS SINGLE
price AS SINGLE
sprice AS SINGLE
sale AS STRING * 1
tax AS STRING * 1
qty AS INTEGER
END TYPE
TYPE reciept
x AS INTEGER
id AS INTEGER
scode AS INTEGER
nam AS STRING * 20
qty AS INTEGER
price AS SINGLE
tcost AS SINGLE
END TYPE
DIM pr AS product
DIM bill AS reciept
DIM count AS INTEGER
count = 0
RESTORE pdata
FOR i = 1 TO 9 STEP 1 'here I loaded all product information in pr
READ id, nam$, cost, price, sprice, sale$, tax$, qty
NEXT
FOR i = 0 TO count STEP 1'outputs bill
PRINT bill.nam; (i); " "; bill.price; (i); " "; bill.qty; (i)
NEXT
PRINT bill.tcost
SLEEP 10 'this command just pauses the program for 10 seconds
END
SUB trans
RESTORE t1data
FOR j = 1 TO 22 STEP 1 'loading transaction info
READ scode, id, qty
FOR i = 1 TO 9 STEP 1
IF id = id THEN 'checking for id match
nam = nam 'copying name of product to bill
qty = qty - billqty 'updating qty of product
IF prsale$ = "Y" THEN 'checks if item is on sale
billprice = prsprice 'sets bill price to sale price if on sale
ELSE
billprice = prprice
END IF
IF prtax$ = "Y" THEN 'checks if there is tax
billprice = billprice * 1.15 'adjust price for tax (15%)
END IF
billtcost = billtcost + billqty * billprice 'update total cost
count = count + 1
END IF
NEXT
NEXT
END SUB