Moloch
11-30-2008, 08:54 PM
Heya Guys and or Gals!
I've been working with Psuedocode for college and we're playing around with loops. I have this code written up but it just looks outright terrible.
Would anyone be able to rewrite the module so it's a bit cleaner?
finishLine()
investment = 10,0000
tBills = 0
tBillRate = .03
bonds = 0
corpBondRate = .06
stocks = 0
stocksRate = .09
for yearIncrement = 1 to 40
tBills = tBills + investment *1.03
yearIncrease = investment * tBillrate
if yearIncrement = 1 then
print investment, investmentReturn, tBillRate
else
print tBills, investmentReturn, tBillRate
endif
bonds = bonds + investment *1.06
if yearIncrement = 1 then
print investment, investmentReturn, corpBondRate
else
print bonds, investmentReturn, corpBondRate
endif
stocks = stocks + investment * 1.09
if yearIncrement= 1 then
print investment, investmentReturn, stocksRate
else
print stocks, investmentReturn, stocksRate
endif
yearIncrement = yearIncrement + 1
if yearIncrement= 10 then
numberYears = numberYears + 10
if yearIncrement = 20 then
numberYears = numberYears + 10
if yearIncrement = 30 then
numberyears = numberYears + 10
endif
endif
endif
perform FinishLine()
Return
If not one has replied by 2am Eastern time tonight go ahead and delete this thread and I'll turn in as is. Thanks people:)
I've been working with Psuedocode for college and we're playing around with loops. I have this code written up but it just looks outright terrible.
Would anyone be able to rewrite the module so it's a bit cleaner?
finishLine()
investment = 10,0000
tBills = 0
tBillRate = .03
bonds = 0
corpBondRate = .06
stocks = 0
stocksRate = .09
for yearIncrement = 1 to 40
tBills = tBills + investment *1.03
yearIncrease = investment * tBillrate
if yearIncrement = 1 then
print investment, investmentReturn, tBillRate
else
print tBills, investmentReturn, tBillRate
endif
bonds = bonds + investment *1.06
if yearIncrement = 1 then
print investment, investmentReturn, corpBondRate
else
print bonds, investmentReturn, corpBondRate
endif
stocks = stocks + investment * 1.09
if yearIncrement= 1 then
print investment, investmentReturn, stocksRate
else
print stocks, investmentReturn, stocksRate
endif
yearIncrement = yearIncrement + 1
if yearIncrement= 10 then
numberYears = numberYears + 10
if yearIncrement = 20 then
numberYears = numberYears + 10
if yearIncrement = 30 then
numberyears = numberYears + 10
endif
endif
endif
perform FinishLine()
Return
If not one has replied by 2am Eastern time tonight go ahead and delete this thread and I'll turn in as is. Thanks people:)