Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an application that calculates the amount of money earned on an investment. Prompt the user to enter an investment amount, the number of years

Write an application that calculates the amount of money earned on an investment.

Prompt the user to enter an investment amount, the number of years for the investment, and the interest rate.

Display an error message if the user enters 0 for any of these values; otherwise, display the total amount (balance) for each year of the investment.

Save the file as Investment.java.

Java Program

Specific instructions:

  • Program must use 4 methods to accomplish the following:
    • Prompt for and return the investment amount
    • Prompt for and return the number of years
    • Prompt for and return the interest rate
    • Display the calculations

Your output must resemble the sample below. Notice the formatting of the dollar amounts. You need to display 2 decimal places for all amounts, even for those with whole dollar amounts.

Enter investment amount: 100

Enter number of years: 10

Enter interest rate : 0.5

Your Investment at 5..0% is:

After year 1 $105.00

After year 2 $110.25

After year 3 $115.76

After year 4 $121.55

After year 5 $127.63

After year 6 $134.01

After year 7 $140.71

After year 8 $147.75

After year 9 $155.13

After year 10 $162.89

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

More Books

Students also viewed these Databases questions