Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a application that prompts a user for the number of years the user has until retirement and then the amount of money the user

Make a application that prompts a user for the number of years the user has until retirement and then the amount of money the user can save annually. If the user enters 0 or a negative number for either value, reprompt the user until valid entries are made. Assume that no interest is earned on the money. Display the amount of money the user will have at retirement

import java.util.Scanner;

public class RetirementGoal

{

public static void main (String[] args)

{

//put code here

}

}

2, Modify the RetirementGoal application to display the amount of money the user will have if the user earns 4% interest on the balance every year.

import java.util.Scanner;

public class RetirementGoal2

{

public static void main (String[] args)

{

Scanner input = new Scanner(System.in);

int years;

int saveAmount;

int total;

final double RATE;

// perform interest calculation

System.out.print("How many years until retirement? >> ");

years = input.nextInt();

while(years <= 0)

{

System.out.println("Years cannot be 0 or negative");

System.out.print("Please renter years >> ");

years = input.nextInt();

}

System.out.print("How much can you save annually? >> ");

saveAmount = input.nextInt();

while(saveAmount <= 0)

{

System.out.println("Amount cannot be 0 or negative");

System.out.print("Please renter amount to save annually >> ");

saveAmount = input.nextInt();

}

total = saveAmount * years;

System.out.println("If you save $" + saveAmount +

" for " + years + " years without interest, you will have $" + total);

double total2 = 0;

for(int y = 0; y < years; ++y)

{

total2 += saveAmount;

}

System.out.println("If you save $" + saveAmount +

" for " + years + " years, with " + (RATE * 100) +

"% interest, you will have $" + total2);

}

}

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

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions

Question

Define plant location.

Answered: 1 week ago

Question

Define plant location.

Answered: 1 week ago

Question

Formal Education explain?

Answered: 1 week ago