10. A. Write an application that prompts a user for the number of years the user
ID: 3543779 • Letter: 1
Question
10. A. Write an application that prompts a user for the number of years the user has until retirement and the amount of money the user can save annually. If the user enter 0 or a negitive number for either value, reprompt the user until valid entries are made. Assume that no interest is earned on the money. Dispaly the amountof money the user will have at retirement.
B. Modify the RetirementGoal application to display the amount of money the user will have if the user earns 5% interest on the balance every
***Note**** The code needs to be wrote in simple terms not in advanced terms it cannot include any coding methods past the 6th chapter because we have not made it any further than the 6th chapter.
Explanation / Answer
package chegg.answers.DB;
import java.util.Scanner;
/*
* 10. A. Write an application that prompts a user for the number of years the user has until retirement
* and the amount of money the user can save annually.
* If the user enter 0 or a negitive number for either value, reprompt the user until valid entries are made.
* Assume that no interest is earned on the money. Dispaly the amountof money the user will have at retirement.
B. Modify the RetirementGoal application to display the amount of money the user will have
if the user earns 5% interest on the balance every
***Note**** The code needs to be wrote in simple terms not in advanced terms it cannot include any coding methods past the 6th chapter because we have not made it any further than the 6th chapter.
*/
public class RetirementGoal
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
double years, annualAmt;
System.out.println("Welcome to the Retirement Goal Application! ");
System.out.print("Please input the estimated number of years you will work until retirement: ");
years = console.nextDouble();
while(years<=0)
{
System.out.print("Values inputed cannot be zero or negative."
+ " Please Re-Input the value: ");
years = console.nextDouble();
}
System.out.print(" Please input the estimated amount of money"
+ " you are able to put into savings annually: ");
annualAmt = console.nextDouble();
while(annualAmt<=0)
{
System.out.print("Values inputed cannot be zero or negative."
+ " Please Re-Input the value: ");
years = console.nextDouble();
}
System.out.println(" The Retirement Goal Application estimates that you will have: ");
System.out.println("$ " + (years * annualAmt));
//For Part B, interest earning, add this line of code
//System.out.println("$ " + ((years * annualAmt) + (annualAmt * years * .05)));
System.out.println("Available the year you retire.");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.