Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program help please!
#11
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


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
Reply


Messages In This Thread
Program help please! - by SeeSpot - 03-01-2003, 01:11 AM
Program help please! - by pr0gger - 03-01-2003, 01:37 AM
Program help please! - by SeeSpot - 03-01-2003, 01:52 AM
Program help please! - by pr0gger - 03-01-2003, 02:08 AM
Program help please! - by SeeSpot - 03-01-2003, 10:32 AM
Program help please! - by toonski84 - 03-01-2003, 10:56 AM
Program help please! - by SeeSpot - 03-01-2003, 11:27 AM
Program help please! - by SeeSpot - 03-01-2003, 11:31 AM
Program help please! - by SeeSpot - 03-03-2003, 04:24 AM
Program help please! - by toonski84 - 03-03-2003, 04:51 AM
Program help please! - by SeeSpot - 03-03-2003, 05:06 AM
Program help please! - by toonski84 - 03-03-2003, 05:13 AM
Program help please! - by SeeSpot - 03-03-2003, 05:24 AM
Program help please! - by SeeSpot - 03-03-2003, 05:42 AM
Program help please! - by pr0gger - 03-03-2003, 05:58 AM
Program help please! - by SeeSpot - 03-03-2003, 06:29 AM
That's not a bug... - by Glenn - 03-03-2003, 08:22 AM
Program help please! - by SeeSpot - 03-03-2003, 10:52 AM
Program help please! - by toonski84 - 03-03-2003, 02:50 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)