Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

=+c) Interpret the coefficient of Saturday in this model.

Answered: 1 week ago