# I need help with this assignment

November 26, 2010 at 23:28:22
Specs: Windows XP
 Hargrove Foods wants to have a program that allows entry of prices until the users enters -9999 for the price. These prices must be stored in an array. Then your program will print out each price (excluding the -9999) and the total price to charge added together displayed as a running total. The running total must be displayed after the input of all the numbers as shown below. The last value represents the total price.Sample program execution:Please enter price of the item (-9999 to exit): 5.35Please enter price of the item (-9999 to exit): 8.25Please enter price of the item (-9999 to exit): 10.75Please enter price of the item (-9999 to exit): 7.35Please enter price of the item (-9999 to exit): -9999Price ---- Total5.35 -------5.358.25 -------13.610.75 ------24.357.35 ---------31.7I need help adding the total to the prices.Here is what I have so far;' Declare variables and arrayDIM price(1000) AS STRINGDIM count AS INTEGERDIM numitems AS INTEGERdim total(1000) as stringcount = 1' Priming read entered into an arrayINPUT "Enter a price (-9999 to exit): ", price(count)' Continue until a sentinel value is addedDO WHILE price(count) <> "-9999" ' Add 1 to the counter used as the subscript count = count + 1 ' Read the next item INPUT "Enter a price (-9999 to exit): ", price(count)LOOP' Since the last item entered is the sentinel value subtract 1 from the number' of items to exclude the sentinel value.numitems = count - 1PRINTPRINTPRINTPRINT "Prices entered" , "total",' Print out the itemsFOR count = 1 TO numitems NEXT countsleepEND

See More: I need help with this assignment

#1
November 27, 2010 at 00:34:14
 You should say what help you need.=====================================Life is too important to be taken seriously.M2

Report •

#2
November 27, 2010 at 01:04:44
 I need help adding the total to the prices.Here is what I have so far;' Declare variables and arrayDIM price(1000) AS STRINGDIM count AS INTEGERDIM numitems AS INTEGERdim total(1000) as stringcount = 1' Priming read entered into an arrayINPUT "Enter a price (-9999 to exit): ", price(count)' Continue until a sentinel value is addedDO WHILE price(count) <> "-9999"' Add 1 to the counter used as the subscriptcount = count + 1' Read the next itemINPUT "Enter a price (-9999 to exit): ", price(count)LOOP' Since the last item entered is the sentinel value subtract 1 from the number' of items to exclude the sentinel value.numitems = count - 1PRINTPRINTPRINTPRINT "Prices entered" , "total",' Print out the itemsFOR count = 1 TO numitemsNEXT countsleepEND

Report •

#3
November 27, 2010 at 07:50:35
 I need help adding the total to the prices.Probably because you're storing the prices as Strings, instead of something sane like Integer.How To Ask Questions The Smart Way

Report •

Related Solutions

#4
November 27, 2010 at 08:56:55
 As you are entering currency values I would declare the price as a currency data type. If you don't want the currency symbol then a single precision floating point at least. The total should be a numerical variable as well unless you want to do a number to string conversion.Stuart

Report •

#5
November 27, 2010 at 17:22:08
 The issue I am having is with the accumulator not working as i would want it to.sum=sum+price(1000)My mistake I originally had " " around the -9999 which forced me to make price as a string when it should have been a single. But here is the new code.' Declare variables and arrayDIM price(1000) AS singleDIM count AS INTEGERDIM numitems AS INTEGERdim total(1000) as singledim sum as singlecount = 1' Priming read entered into an arrayINPUT "Enter a price (-9999 to exit): ", price(count)' Continue until a sentinel value is addedDO WHILE price(count) <> -9999 ' Add 1 to the counter used as the subscript count = count + 1 ' Read the next item INPUT "Enter a price (-9999 to exit): ", price(count)LOOPnumitems = count - 1PRINTPRINTPRINTsum=sum+price(1000)PRINT "Prices" , "total"' Print out the itemsFOR count = 1 TO numitems PRINT price(count) , sumNEXT countsleepEND

Report •

#6
November 27, 2010 at 17:37:55
 never mind got it' Declare variables and arrayDIM price(1000) AS singleDIM count AS INTEGERDIM numitems AS INTEGERdim total(1000) as singledim sum as singledim x as integercount = 1' Priming read entered into an arrayINPUT "Enter a price (-9999 to exit): ", price(count)' Continue until a sentinel value is addedDO WHILE price(count) <> -9999 ' Add 1 to the counter used as the subscript count = count + 1 ' Read the next item INPUT "Enter a price (-9999 to exit): ", price(count)LOOPnumitems = count - 1sum=0PRINTPRINTPRINTPRINT "Prices" , "total"' Print out the itemsFOR count = 1 TO numitems sum=sum+price(count) PRINT price(count) , sumNEXT countsleepEND

Report •