Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Type or paste question here Compound Interest Purpose: The purpose of this lab is to practice writing programs that can accept user input using the

image text in transcribedimage text in transcribedType or paste question here

Compound Interest Purpose: The purpose of this lab is to practice writing programs that can accept user input using the Scanner class. The major concepts covered in this lab include the Scanner class and more complex math operations. Task: Create a project called CompoundInterest_FirstName_LastName or Lab3_FirstName_LastName. Remember to include comments summarizing the program. 1. Import the Scanner class and declare a variable for the Scanner class. This variable is used to read from the keyboard. 2. Declare three variables of type double that are used to hold the user's input of three different numbers. To provide a hint about the variable names, you will be requesting an initial balance, an interest rate, and a number of years later in this program. These variables can be initialized to 0. 3. Declare a fourth variable of type double that will hold the final amount after some calculations are performed using the other three double variables. This variable can be initialized to 0. 4. Print a request to the user asking for the principal balance. Store the user's input into the first of the three variables you declared in step 2. 5. Print a request to the user asking for the interest rate as a percentage. Divide the user's input by 100 and store the result into the second of the three variables you declared in step 2 6. Print a request to the user asking for the number of years. Store the user's input into the third of the three variables you declared in step 2. 7. Use the following equation to calculate the final amount: A = P *(1 + r) A is the final amount, P is the principal balance, r is the interest rate, and t is the number of elapsed years. You will need to use the Math.pow() method in this calculation. The result of this equation is stored in the double variable declared in step 3. Two common errors to avoid: make sure the interest rate was divided by 100 in order to convert it from a percentage to a decimal in step 5, and make sure you are performing the math operations for this equation in the proper order. 8. Print a message to the user indicating the final amount. Refer to the following for an example of the expected program flow (the sequence of user inputs and the final output): run: Please specify the initial balance: 100 Please specify the interest rate (%): 3 Please specify the number of elapsed years: 5 The final amount with interest is $115.92740743 BUILD SUCCESSFUL (total time: 4 seconds)

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions