Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

design a gui for the following java program import java.util.Scanner; public class RetirementCalculator { public static void main(String[] args) { Scanner scanner = new Scanner(System.in);

design a gui for the following java program

import java.util.Scanner;

public class RetirementCalculator {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

// Gather user input

System.out.print("Enter client name: ");

String name = scanner.nextLine();

System.out.print("Enter retirement scenario name: ");

String scenarioName = scanner.nextLine();

System.out.print("Enter current retirement nest egg ($): ");

double nestEgg = scanner.nextDouble();

System.out.print("Enter average annual rate of return (%): ");

double rateOfReturn = scanner.nextDouble() / 100;

System.out.print("Enter current salary ($): ");

double currentSalary = scanner.nextDouble();

System.out.print("Enter yearly contribution amount ($): ");

double yearlyContribution = scanner.nextDouble();

System.out.print("Enter yearly salary increase (%): ");

double yearlySalaryIncrease = scanner.nextDouble() / 100;

System.out.print("Enter number of years to retirement: ");

int yearsToRetirement = scanner.nextInt();

System.out.print("Enter desired income at retirement for active years ($/year): ");

double activeYearsIncome = scanner.nextDouble();

System.out.print("Enter desired income at retirement after active years ($/year): ");

double postActiveYearsIncome = scanner.nextDouble();

// Calculate retirement data

double totalContribution = 0;

double totalInterestEarned = 0;

double yearlyWithdrawal = activeYearsIncome;

double postActiveWithdrawal = postActiveYearsIncome;

int retirementYear = 2023 + yearsToRetirement;

for (int year = 2023; year < retirementYear; year++) {

// Calculate interest earned

double interestEarned = nestEgg * rateOfReturn;

totalInterestEarned += interestEarned;

// Calculate contribution

totalContribution += yearlyContribution;

yearlyContribution *= (1 + yearlySalaryIncrease);

// Update nest egg balance

nestEgg += interestEarned + yearlyContribution;

// Update withdrawal amounts

if (year >= 65 && year <= 80) {

yearlyWithdrawal = activeYearsIncome;

} else if (year > 80) {

postActiveWithdrawal = postActiveYearsIncome;

}

}

// Print retirement data

System.out.println(" Retirement data for " + name + " (" + scenarioName + "): ");

System.out.printf("Total contribution: $%,.2f ", totalContribution);

System.out.printf("Total interest earned: $%,.2f ", totalInterestEarned);

System.out.printf(" Yearly withdrawal: ");

System.out.printf("Active years: $%,.2f ", yearlyWithdrawal);

System.out.printf("Post-active years: $%,.2f ", postActiveWithdrawal);

scanner.close();

}

}

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_2

Step: 3

blur-text-image_3

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 SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago

Question

=+1. What are the five general goals in delivering bad news? [LO-1]

Answered: 1 week ago