Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is an \"extra credit assignment, more difficult than most. Since get a poin

ID: 3586300 • Letter: T

Question

This is an "extra credit assignment, more difficult than most. Since get a point in the course. irs an extra credit challenge, 'il give only minimal help. This assignment is one of the hardest ways to Improve your Retirement the company). program based on these rules. Eligibility for retirement is based on age (how oid the worker is and service (how long the worker has worked at 1. 30 and out: anyone with 30 years of service can retire, no mater how old 2. You can retire if you are 65 years old, no matter how many years of service 3. You can retire at age 60 with 20 years of experience. 4. You can retire at age 55 with 25 years of experience Use java The program should ask for the are not immediately eligible. For example, a person 21 yoars old with 1 year experience can retire in 29 can reire in 24 years (under rule 4); a 41 year old with 1 year can retire in 19 years (under rule 3; a 51 year old with 1 year can retire in 14 yoars (under nule 2), DEMO: 62 years (under rule 1) a person 31 years old with 1 year experience with 19 years of service.

Explanation / Answer

So this program checks if the retirement age is reached or not

there are four condition

1. anyone with 30 years of service can retire without boundation of age i.e anyone with 30 years or more (as it will include 30 years of service also) years of service can retire

2.anyone with 65 years can retire without boundation of service year i.e anyone with 65 years or more (as it will include 65 years of age) years can retire

3.also anyone with age 60 years with 20 years of experience which will include being more than that also can retire

4.also anyone with 55 years with 25 years of experience which will include being more than that also can retire.

So, according to all thee conditions the first if statement is made which will result in positive retirement age.

then after other conditions are made to find the years of wait for retirement which include checking all the above 4 conditions and choose the least years of wait (denoted by temp here).

we are using t1,t2 and temp for temporary calculations and temp stores the years.

import java.util.Scanner;
public class Test {

public static void main(String args[]) {
Scanner scnr = new Scanner(System.in);
int t1,t2,temp,s,y;

//taking input of age and service using java.util.scanner nextint takes the next integer as input
System.out.print("Enter your age");
y=scnr.nextInt();
System.out.print("Enter your service years");
s=scnr.nextInt();

//for the initial condition check
if( s >= 30 || y >= 65 || (y>=60 && s>=20) || (y>=55 && s>=25))
{
System.out.print("Eligible for retirement");
}else {

//else to find the wait
temp=65-y; //checking with first condition
if(temp>(30-s))
temp=30-s;

//checking with ssecond condition but also taking in account if it is lesser then the one calculated earlier
//checking for third condition which has conditions inside   

if(y<55)
{t1=55-y; t2=t1+s;

//getting the age difference and adding it in service to know if till that time it will 25 year of service

//if age less than 55 then we have to check for service greater andd less than 25
if(t2<25)
{t1=t1+(25-t2); //because both age and service condition should be fulfilled
}

//and check if it gives the least amount of wait
if(t1<temp)
temp=t1;
}

//then check for greater than 55 with service less than 25 as greater than has already been considered
else if(y>=55)
{//since age criteria is matched what is needed is service it is checked for least wait
if((s-25)<temp)
temp=s-25;
}

//as for 55 the conditions are checked for 60 years of age also.
if(y<60)
{t1=60-y; t2=t1+s;
if(t2<20)
{t1=t1+(20-t2);
}
if(t1<temp)
temp=t1;
}
else if(y>=60)
{
if((s-20)<temp)
temp=s-20;
}
  
// and then the years still needed to retire are printed whichis in temp
System.out.print("Not currently eligible for retirement still need" + temp + "years");
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote