Question: java program Lab 1 0 : Create a project called Continuallnterest _ FirstName _ LastName or Lab 1 0 _ FirstName _ LastName. Remember to
java program
Lab : Create a project called ContinuallnterestFirstNameLastName or
LabFirstNameLastName. Remember to include comments describing your program. A key
component of this lab should be comments describing the methods used.
The steps provided are broken down into a bottomup implementation. Methods implemented in
earlier steps will be used in later steps.
First, implement a method that will handle the calculation of the compound interest. This method
will take a double for the principal amount, a double for the interest rate, and an int for the
number of years. This method will return a double for the final amount.
In the body of this method, use the following formula to calculate compound interest:
where is the principal amount, is the interest rate, is the number of years, and is the final
amount. Be careful about the order of operations in this formula.
Next, implement a method that will handle printing the output to the console with proper
formatting. This method will take an int for the number of years and a double for the final
amount. This method will not return anything. The final amount must be formatted to two
decimal places.
In the main method, declare a Scanner that accepts input from the keyboard. Declare variables
for the principal amount, interest rate, number of years, and final amount. The data types should
match what is expected for the other methods in this program.
Make requests to the user to enter the principal amount, interest rate, and number of years. The
interest rate will be requested as a percent, so make sure this is converted to a decimal before
performing any calculations.
Write a for loop to go through each year of the loan. This loop will start with year and end with
the year the user input. Within this for loop, do the following:
Call the first method implemented to calculate the final amount. Make sure the principal
amount, interest rate, and the current year based on the for loop are passed into this
method and that the result of calling this method is assigned to the final amount.
Call the second method implemented to print the output to the console. Make sure the
current year and final amount are passed into this method.
Examples:
The following example assumes the user enters an initial value of an interest
rate of and a number of elapsed years of Keep in mind the rate will be converted
to for the calculation.
Please enter the principal amount:
Please enter the interest rate:
Please enter the number of elapsed years:
After years the final amount is $
After years the final amount is $
After years the final amount is $
After years the final amount is $
After years the final amount is $
After years the final amount is $
After years the final amount is $
After years the final amount is $
After years the final amount is $
After years the final amount is $
After years the final amount is $
The following example assumes the user enters an initial value of an interest
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
