03-03-2003, 05:06 AM
I can't figure it out. The answers come back wrong but only off by a few.
Here is the contents of the dat file:
"Coke Classic",19.8
"Pepsi",18.8
"Diet Coke",7.7
"Diet Pepsi",4.8
"Dr. Pepper",4.3
"Sprite",3.5
"7-Up",3.4
"Mountain Dew",2.9
Here is the prog. It is running in QBasic 1.1
Here is the contents of the dat file:
"Coke Classic",19.8
"Pepsi",18.8
"Diet Coke",7.7
"Diet Pepsi",4.8
"Dr. Pepper",4.3
"Sprite",3.5
"7-Up",3.4
"Mountain Dew",2.9
Here is the prog. It is running in QBasic 1.1
Code:
CLS
PRINT "Soft Drinks Market Share Gross Sales"
PRINT TAB(20); "Percent"
PRINT
OPEN "asgn5b2a.dat" FOR INPUT AS #1
DO WHILE NOT EOF(1)
INPUT #1, softDrink$, percentMarketShare
LET grossSales = 40000000000#
LET grossSales = (grossSales * percentMarketShare) / 100
LET totalPercentMarketShare = totalPercentMarketShare + percentMarketShare
LET totalGrossSales = totalGrossSales + grossSales
LET a$ = "\ \ ##.##% $$##,###,###,###"
PRINT USING a$; softDrink$; percentMarketShare; grossSales
LOOP
LET B$ = "\ \ ##.##% $$##,###,###,###"
PRINT
PRINT TAB(20); "______ _______________"
PRINT USING B$; "Total"; totalPercentMarketShare; totalGrossSales
CLOSE #1 'Close file
END