PDA

View Full Version : Small Request With College Psuedocode Assignment



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:)

ShowerThoughts
11-30-2008, 08:57 PM
Which p language is this? vb?

A G E N T
11-30-2008, 09:21 PM
Hopefully I got this right :)


finishLine()
investment = 100000
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
bonds = bonds + investment *1.06
print investment, investmentReturn, corpBondRate
stocks = stocks + investment * 1.09
print investment, investmentReturn, stocksRate
else
print tBills, investmentReturn, tBillRate
print bonds, investmentReturn, corpBondRate
print stocks, investmentReturn, stocksRate
endif
yearIncrement = yearIncrement + 1 // do you mean to call this when already in a for loop
case yearIncrement of
10, 20, 30 : numberYears = numberYears + 10;
endcase

if yearIncrement= 10 then

endfor


perform FinishLine()
Return

Moloch
11-30-2008, 09:40 PM
Which p language is this? vb?

Just psuedocode :)

Moloch
11-30-2008, 09:43 PM
Agent your a genius! Looks great to me. The 2nd call at the bottom was a mistake been up all night revising it xD