### Help! Investment program

Write a program that finds how many years it takes for the
value of Cleo’s investment to exceed the value of Daphne’s investment and then displays the value of both investments at that time.

I wrote the program, but it says it took 27 years for Cleo to exceed Dapne's investment.

Daphne invested 100\$ with 10% simple interest.
Cleo invested 100\$ with 5% compund interest.

 ``123456789101112131415161718192021222324252627282930`` ``````struct bank{ double balance; double interest; }; main(){ bank Daphne = { 100, 0.10 }; bank Cleo = { 100, 0.05 }; int years = 0; while(Daphne.balance >= Cleo.balance){ Daphne.interest *= 100; Daphne.balance += Daphne.interest; Daphne.interest = 0.10; Cleo.interest *= Cleo.balance; Cleo.balance += Cleo.interest; Cleo.interest = 0.05; years++; } cout << "It took " << years << " years for Cleo to exceed the value of Daphne's investment.\n"; cout << "Cleo's current balance is \$" << Cleo.balance << ".\n"; cout << "Daphne's current balance is \$" << Daphne.balance << ".\n"; }``````

Is this the correct formula? (I'm bad at maths sorry lol).
Last edited on
Topic archived. No new replies allowed.