Computer Science Canada

please help with a simple thing ...

Author:  b21 [ Fri Jun 11, 2004 10:15 am ]
Post subject:  please help with a simple thing ...

could someone please help me with this...i need it to add up all the prices, when i type in more than 2 things it only adds the 1st one and the 2nd one and none inbetween haha i know this is probably a simple thing but if anyoine could help thatd be cool..haha it looks weird with all the variables but its for the whole big project this is just a little bit of it...thanks alot
*b21

--------------------------------------------------------------------------------------
var companyname : string
var date_ : string
var current, capital, currentL, longterm, ownersE : string
var current1, capital1 : array 1 .. 100 of string
var totalcurrent, totalcapital, totalassets : real
var currentL1, longterm1 : array 1 .. 100 of string
var totalcurrentL, totallongterm, totalL : real
var ownersE1 : array 1 .. 100 of string
var totalLandownersE, totalownersE : real
var font : int
var price,price1, price2, price3, price4 : array 1 .. 100 of real
var total, total1, total2, total3, total4 : real := 0
var j, k, l, m, n : int := 0
var p_rice, p_rice1, p_rice2, p_rice3, p_rice4 : real
var total_, total_1, total_2 : real
var totalZ : real := 0
total := 0
total2 := 0
total3 := 0
total4 := 0
total_ := total + total1
total_1 := total2 + total3
total_2 := total_1 + total4

put "Enter next to continue!"
put ""
put "List your Current Assets: " ..
get current : *
put "Enter Price: " ..
get p_rice

for i : 1 .. 100
put " : " ..
get current1 (i) : *
exit when current1 (i) = "next"
put "Enter Price:" ..
get price(i)
j := j + 1
end for

put "Current Assets"
put ""
put current, "\t", p_rice
for i : 1 .. j
put current1 (i), "\t", price(i)
total := p_rice + price(i)
end for

put "Total Current Assets $", total

Author:  Delos [ Fri Jun 11, 2004 11:22 am ]
Post subject: 

1) Use [ code] tags.
2) A bit of commenting would help us understand what's going on Rolling Eyes .
3)
Well, I can't figure out exactly what the code is trying to do...but I think's got something to do with this idea:
- get a bunch of prices and then add them together
OR
- get a bunch of prices, and the number of items thereof, and add them together

Either way, you don't need to use arrays, just a (couple of) counter(s) and a couple of temp vars in which to store the input before adding it to the counters!

Author:  romper [ Wed Jun 16, 2004 9:32 pm ]
Post subject: 

You might want to add a :* after your get varables that means it gets the whole line and so if you put like assests: pool table .. it doesn't make the table go to the price! if that helps you out at all if not pm me!


: