Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Question:

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

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

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

60 Workplace safety risks.

Answered: 1 week ago