Hello again, sorry to bombard the forum with noob questions but I was stuck on this problem yesterday, came back today and still can't figure it out.
Exercise : Daphne invests $100 at 10% simple interest, that is every year daphnes value increases by 10% of the principle(original investment).
Cleo invests $100 at 5% compound interest, the next year earns 5% of 105, so on and s on.
Write a program that calculates how long it will take in years for Cleo's investment to have a greater value than Daphne's, also output after how many years this occurs.
Here's my code.. nothing happens though, all it does is open up a screen that says Hello.(i put that in there because the screen was blank) should I be declaring the variables inside the "do" ? or should I be using a for loop?
Notice that this here -> double cleoincrement = (cleo * .05); will only initialize cleoincrement.
It doesn't make it change every time cleo changes. You have to do it yourself:
1 2 3 4 5 6 7 8 9 10 11 12
//...
do
{
daphne += daphneincrement;
cleo += cleoincrement;
//add this here!
cleoincrement=(cleo * .05);
years += 1;
} while (cleo <= daphne);
//...
One of your classmates posted the same questions in s thread titled 'Exercise'. You should read the responses as they likely address your question as well.