Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a simple JAVA on building a compound interest calculation, using a loop and a boolean variable. Here is the scenario The bank has

I have a simple JAVA on building a compound interest calculation, using a loop and a boolean variable. Here is the scenario

The bank has an account for those who want to become a millionaire you deposit a sum of money once, select a guaranteed interest rate for growth, then you cant touch the money until it grows to a million dollars. You know the starting value (user enters in any starting amount), the ending value ($1 million), and the rate of growth, but you dont know how long it will take to reach that value. The money grows in cycles using compound interest.

The account balance will grow using compound interest the amount of growth is added to the balance, and that new balance will be used to calculate the next amount of growth. That is, if the account balance is $25, and the interest rate is 10%, then the account will add 10% of $25 ($2.50) to the balance (25 + 2.50 = $27.50). In the next iteration through the loop, that new balance of $27.50 will grow by 10%. A cycle can be a year, a month, a day that detail isnt important here, just that the account grows by compound interest in each cycle.

The code will asks the user how much money they will deposit and what interest rate they choose. In the program, use a loop to calculate the growth in the account balance, and keep track of the number of iterations. When the balance is at least $1,000,000, end the loop and print out how many cycles it took to reach that sum. Include a message about how many cycles it takes to reach the sum of $100,000 as well. This message should only print once, not every time the account balance is greater than $100,000. (Hint: use a Boolean variable to determine if you are still searching for that balance or have already found it and printed the message.)

The end result would look like this;

How much money are you putting in the bank? //System.out.println

1000 //user input

What is the interest rate? //System.out.println

2.5 //user input

After 187 cycles, it's worth mor then 100,000 //System.out.println

After 280 cycles, its' worth more then 1,000,000 //System.out.println

Any help on this one is greatly appreciated. Thank you!!!!

I started what I thought would be a good start but I think I am far away from where I need to be;

//declare variables here double balance; int yearsToMillion = 0, yearsTo100K = 0;

double startAmount = 100000, interestGain, totalGain = 0, interestRate; Boolean cycles = true;

System.out.print("How much money are you putting in the bank? "); balance = stdIn.nextDouble();

System.out.print("What is the interest rate? "); interestRate = stdIn.nextDouble();

while (startAmount < 1000000) {

}//end second while loop

//calculations totalGain = startAmount * (Math.pow((1 + interestGain / 100), TimePeriod));

System.out.println("After " + " cycles, it's worth more than $" +);

System.out.println("After " + " cycles, it's worth more than $" +); */

}//end main

}//end class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions