Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Purpose: Suppose you are working at a financial company. The company has an investment product that allows investors to save the same amount of money

Purpose: Suppose you are working at a financial company. The company has an investment
product that allows investors to save the same amount of money each month for up to 6 months
with an annual interest rate of 5%. The interest is paid at the end of each month. The financial
company wants to develop an app to let potential users enter the amount they want to save
each month and display the account balance after 1,2,3, and 6 months.
This program will emphasize the following concepts:
Declaring and using variables
Declaring and using constants
Reading user input
Performing numeric operations
String concatenation to format output
Lesson: To prepare for performing the calculations, consider a simpler case: what if we only
allow investors to save for two months? Can you write a program to display the account balance
after each month?
Suppose an investor saves $100 each month into the account for two months. Since the annual
interest rate is 5%, the monthly interest rate is 0.0512=0.00417.
After the 1st month, the value of the account becomes:
100*(1+0.00417)=100.417
After the 2nd month, the value of the account becomes:
(100+100.417)**(1+0.00417)=201.252
Your algorithm will include three major steps:
Get input from users (how much they want to invest each month for two months)
Calculate the balance after the 1st month and display the result
Calculate the balance after the 2nd month and display the result
Task:
Create a new Java project titled Lab2_FirstName_LastName.
You must include comments describing key parts of this program.
Declare a Scanner called input that accepts input from the keyboard.
Remember to include the proper import statement to use the Scanner class.
Declare a constant of type double called MONTHLY_INTEREST_RATE. Initialize this
final variable to the correct value.
Declare a variable of type double called monthlyDeposit. Initialize this variable to 0.0
(the user will provide a value later).
Declare another variable of type double called currentValue. Initialize this variable to
be monthlyDeposit. This is the variable to hold the account balance after each month.
Prompt the user to input how much they want to save/deposit each month. Use the
appropriate method of the Scanner class to assign the user's input to the
monthlyDeposit variable.
Perform the calculation for the account balance after each month and assign the value to
currentValue.
Display the account balance after 1,2,3, and 6 months as "After the XX month, the
account value is YY." Note that xx will be either First, Second, Third, or Sixth, and YY
will be the corresponding balance.
image text in transcribed

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 Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

What is short-selling and is it legal?

Answered: 1 week ago

Question

Persuasive Speaking Organizing Patterns in Persuasive Speaking?

Answered: 1 week ago