Question In java write a simple retirement planning calculator Retirement Inform
ID: 3767254 • Letter: Q
Question
Question In java write a simple retirement planning calculator Retirement Information and Assumptions Your current age (1 to 75) Current annual income ($ Current retirement savings ($) Expected inflation (0% to 10%)help Desired retirement age (1 to 75) Number of years of retirement income (1 to 40) Income replacement at retirement (0% to 100%) Pre-retirement investment return (-12% to 12%) using a format similar to this import java.util.Scanner; public class Mortgage { public static void main(String args[]){ Scanner sc = new Scanner(System.in); //double principal = 200000; System.out.print("Enter Principal: "); double principal = sc.nextDouble(); // Annual interest rate System.out.print("Enter Yearly Interest Rate: "); double rate = sc.nextDouble(); // Monthly intertest rate rate = rate/100/12; // Term in years System.out.print("Enter Term (years): "); int term = sc.nextInt(); // Term in months term = term * 12; double payment = (principal * rate) / (1 - Math.pow(1 + rate, -term)); // round to two decimals payment = (double)Math.round(payment * 100) / 100; System.out.println("Payment: " + payment); } }
Explanation / Answer
I am pasting below the required code. At last, you need to insert the formula for final calcualtion.
import java.util.Scanner;
public class RetirementCalc {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
//current age;
System.out.print("Enter your current age (1-75): ");
int currAge = sc.nextInt();
while(currAge < 1 || currAge > 75) {
System.out.println("Age must be between 1 - 75. Enter: ");
currAge = sc.nextInt();
}
//retirement age;
System.out.print("Enter your retirement age (1-75): ");
int retAge = sc.nextInt();
while(retAge < 1 || retAge > 75) {
System.out.println("Age must be between 1 - 75. Enter: ");
retAge = sc.nextInt();
}
// current annual income
System.out.print("Enter your current annual income: ");
double currAnnualIncome = sc.nextDouble();
// expected inflation rate
System.out.print("Enter expected inflation rate (0-10 %): ");
double infRate = sc.nextDouble();
//no of years of retirement income;
System.out.print("Enter the no of years of retirement income (1-40): ");
int noyri = sc.nextInt();
while(noyri < 1 || noyri > 75) {
System.out.println("Enter a value between 1 - 40. Enter: ");
noyri = sc.nextInt();
}
//Rate of income replacement at retirement
System.out.print("Enter the rate of income replacement at retirement (in %) : ");
double incRepRate = sc.nextDouble();
//Enter the pre-retirement investment return
System.out.print("Enter the pre-retirement investment return (-12 to 12%): ");
double preRetInv = sc.nextDouble();
while(preRetInv < -12 || preRetInv > 12) {
System.out.println("Enter a value between -12 to 12 Enter: ");
preRetInv = sc.nextDouble();
}
// Now you need to enter the formula below for retirement plan calculation
//double output = formula
System.out.println("Output: " + output);
} }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.