Wednesday, 15 July 2015

Output basic compound interest as a list into MessageBox using for loop -



Output basic compound interest as a list into MessageBox using for loop -

i need output basic compound involvement displayed in message box using loop

the message box needs show left column titled "years" , right column showing "amount".

my code displays messagebox 5 times whereas need displayed in list

here have far:

private void button1_click(object sender, eventargs e) { decimal amount; decimal principal = 1000; double rate = 0.05; string msg; msg = "years \t amount"; msg += environment.newline; (int year = 1; year <= 5; year++) { amount = principal * ((decimal)math.pow(1.0 + rate, year)); msg += amount.tostring("c"); msg += environment.newline; } messagebox.show(msg, "compund interest");

private void button1_click(object sender, eventargs e) { decimal amount; decimal principal = 1000; double rate = 0.05; string msg; // start building string here i.e. msg = "header \t header" \t places tab // add together carriage homecoming msg += enviornment.newline (int year = 1; year <= 5; year++) { amount = principal * ((decimal)math.pow(1.0 + rate, year)); // don't overwrite msg append msg += "year number utilize counter \t" += doing below. msg = amount.tostring("c"); // add together carriage homecoming again. } messagebox.show(msg); }

for-loop messagebox

No comments:

Post a Comment