Question
Rebuild Lab 2 Retirement Calculator to have a GUI rather than hardcoded values Project Name: Lab_9_Retirement_Calculator Below is the code from Lab 2 Retirement Calculator:
Rebuild Lab 2 Retirement Calculator to have a GUI rather than hardcoded values
Project Name: Lab_9_Retirement_Calculator
Below is the code from Lab 2 Retirement Calculator:
public static void main(String[] args){ } // TODO code application logic here // Inflation rate private double inflationRate; // Retirement age private int retirementAge; // Current age private int currentAge; // Annual income private double anualIncome; // Percent of income private double percentageOfIncome; // Life expectancy private int lifeExpectancy;
private double nest_egg; // Setters public void setInflationRate(double inflationRate) { this.inflationRate = inflationRate; } public void setRetirementAge(int retirementAge) { this.retirementAge = retirementAge; } public void setCurrentAge(int currentAge) { this.currentAge = currentAge; } public void setAnualIncome(double anualIncome) { this.anualIncome = anualIncome; } public void setPercentageOfIncome(double percentageOfIncome) { this.percentageOfIncome = percentageOfIncome; } public void setLifeExpectancy(int lifeExpectancy) { this.lifeExpectancy = lifeExpectancy; }
// Getter public double getNest_egg() { this.calculateNest_egg(); return nest_egg; } private void calculateNest_egg() { nest_egg = Math.pow(1 + (inflationRate / 100), retirementAge - currentAge) * (anualIncome) * (percentageOfIncome / 100) * (lifeExpectancy - retirementAge); }
static { RetirementCalculator rc = new RetirementCalculator(); rc.setInflationRate(2.48); rc.setRetirementAge(70); rc.setCurrentAge(51); rc.setAnualIncome(60000); rc.setPercentageOfIncome(70); rc.setLifeExpectancy(81);
// Print nest egg results System.out.printf("Nest egg results: $%.2f ", rc.getNest_egg()); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started