Question: In JAVA forLoop method: Method main() should: 1. In the main method call the following methods: a. comparison(); b. forLoop(); c. whileSwitch(); Write method forLoop()

In JAVA forLoop method:

Method main() should:

1. In the main method call the following methods:

a. comparison();

b. forLoop();

c. whileSwitch();

Write method forLoop() to do the following:

1. Return type of void

2. Declare as static

3. Empty parameter list

4. Declare the following variables all of primitive data type double

a. amount = 0;

b. principle;

c. rate;

d. time;

e. ci;

f. t = 1;

5. Instantiate and instance of class Scanner, pass as an argument to the constructor the value System.in

6. Using method System.out.println(), prompt the user to enter the initial principle investment

7. Store the value in the variable principle by setting it equal to method nextDouble() in class Scanner

8. Using method System.out.println(), prompt the user to enter the interest rate

9. Store the value in the variable rate by setting it equal to method nextDouble() in class Scanner

10. Using method System.out.println(), prompt the user to enter the number of years of the investment

11. Store the value in the variable time by setting it equal to method nextDouble() in class Scanner

12. Update the value of variable rate by setting it equal to the calculation (1 + rate / 100) to generate a percentage value

13. In a for loop

a. Loop for the number of years stored in the variable time

b. Set variable t equal (t * rate)

14. Update variable amount setting it equal to the calculation (principle * t)

15. Output to the user the amount

16. Calculate the compounded interest, setting variable ci equal to the calculation (amount principle)

Output to the user their compounded interest

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!