Unscramble This Code to make it run

Unscramble This Code to make it run

Joined: March 30th, 2010, 5:16 pm

March 30th, 2010, 5:17 pm #1

CLS
initalize:
'Print "in intialize routine..."
PRINT TAB(20); "inflation gauge report"
PRINT
PRINT " ", "current", "inflation", "price"
PRINT "item", "price", "rate%", "in 1 yr."
PRINT "----", "-----", "------", "------"
RETURN
GOSUB initialize
GOSUB wrap.up
END
process:
'Print "in the process reutine..."
READ item$, cprice, pprice, numweeks
DO WHILE item$ <> "EOF"
pricechange = (cprice - pprice) / numweeks * 52
GOSUB process
airate = pricechange / pprice
PRINT USING "\ \ #,###.## ###.## #,###.##"; item$; cprice; airate; eprice
eprice = cprice + airate * cprice
airate = airate * 100' make airate display as a percentage
READ item$, cprice, pprice, numweeks
LOOP
RETURN
wrap.up

'**********DATA FOLLOWS**********
DATA 1doz. eggs,0.98,0.84,13
DATA 1lb. butter,1.70,1.62,14
DATA 1gal. milk, 2.20, 2.09, 17
Quote
Like
Share

Joined: February 2nd, 2006, 10:38 pm

March 31st, 2010, 10:30 pm #2

* Where do you get butter for $1.70? Walmart?
Quote
Like
Share

Joined: July 23rd, 2004, 7:51 am

April 5th, 2010, 6:46 pm #3

CLS
initalize:
'Print "in intialize routine..."
PRINT TAB(20); "inflation gauge report"
PRINT
PRINT " ", "current", "inflation", "price"
PRINT "item", "price", "rate%", "in 1 yr."
PRINT "----", "-----", "------", "------"
RETURN
GOSUB initialize
GOSUB wrap.up
END
process:
'Print "in the process reutine..."
READ item$, cprice, pprice, numweeks
DO WHILE item$ <> "EOF"
pricechange = (cprice - pprice) / numweeks * 52
GOSUB process
airate = pricechange / pprice
PRINT USING "\ \ #,###.## ###.## #,###.##"; item$; cprice; airate; eprice
eprice = cprice + airate * cprice
airate = airate * 100' make airate display as a percentage
READ item$, cprice, pprice, numweeks
LOOP
RETURN
wrap.up

'**********DATA FOLLOWS**********
DATA 1doz. eggs,0.98,0.84,13
DATA 1lb. butter,1.70,1.62,14
DATA 1gal. milk, 2.20, 2.09, 17
First, there is no EOF DATA entry, so it will crash after displaying the three items.
Second, the wrap.up label doesn't have the colon.

Your question is a trick question, because it just can't work. Now if the wrap.up stuff were not an issue, perhaps it could run, although it would crash after a little while.

I haven't programmed in QBasic in several years, so correct me if I'm wrong. :)


'--------------------------------
' Uncompiled/tested guess
' But I know it won't work because some of the lines wouldn't work in the original

CLS

GOSUB initialize
GOSUB process
GOSUB wrap.up
END


initalize:
'Print "in intialize routine..."
PRINT TAB(20); "inflation gauge report"
PRINT
PRINT " ", "current", "inflation", "price"
PRINT "item", "price", "rate%", "in 1 yr."
PRINT "----", "-----", "------", "------"
RETURN

process:
'Print "in the process reutine..."
READ item$, cprice, pprice, numweeks
DO WHILE item$ <> "EOF"
pricechange = (cprice - pprice) / numweeks * 52
airate = pricechange / pprice
eprice = cprice + airate * cprice
airate = airate * 100' make airate display as a percentage
PRINT USING "\ \ #,###.## ###.## #,###.##"; item$; cprice; airate; eprice
READ item$, cprice, pprice, numweeks
LOOP
RETURN

wrap.up



'**********DATA FOLLOWS**********
DATA 1doz. eggs,0.98,0.84,13
DATA 1lb. butter,1.70,1.62,14
DATA 1gal. milk, 2.20, 2.09, 17
Last edited by ComputerGhost on April 5th, 2010, 6:49 pm, edited 1 time in total.
Quote
Like
Share