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

Write a program that determines how many years 10 employees have to work before

ID: 3825112 • Letter: W

Question

Write a program that determines how many years 10 employees have to work before retiring.

Here are the steps your program must accomplish.

1.  Define a two-dimension array with 10 rows and 2 columns.

2.  Prompt the user to enter the current age and desired retirement age for 10 employees . Current ages can be between 19 and 70. The valid retirement ages you can enter are 62, 66, and 70.

3. The program must store the current age and desired retirement age for each employee in a different row of the array.

4. The program must compute the number of years the employee has to work before they reach their desired retirement age, and display this output.

Explanation / Answer

EmployeeRetireAge.java

import java.util.Scanner;


public class EmployeeRetireAge {


   public static void main(String args[])
   {
       Scanner scan = new Scanner(System.in);
       int age[][] = new int[10][2];
       for(int i=0; i<age.length; i++){
               System.out.println("Enter the current age: ");
               age[i][0]=scan.nextInt();
               System.out.println("Enter the retire age: ");
               age[i][1]=scan.nextInt();
       }
       for(int i=0; i<age.length; i++){
           System.out.println("Current age: "+age[i][0]+" Retire Age: "+age[i][1]+" Number of years to be worked: "+(age[i][1]-age[i][0]));
       }
     
   }

}

Otutput:

Enter the current age:
21
Enter the retire age:
62
Enter the current age:
33
Enter the retire age:
66
Enter the current age:
70
Enter the retire age:
70
Enter the current age:
34
Enter the retire age:
62
Enter the current age:
44
Enter the retire age:
66
Enter the current age:
55
Enter the retire age:
70
Enter the current age:
19
Enter the retire age:
62
Enter the current age:
35
Enter the retire age:
66
Enter the current age:
44
Enter the retire age:
70
Enter the current age:
32
Enter the retire age:
62
Current age: 21 Retire Age: 62 Number of years to be worked: 41
Current age: 33 Retire Age: 66 Number of years to be worked: 33
Current age: 70 Retire Age: 70 Number of years to be worked: 0
Current age: 34 Retire Age: 62 Number of years to be worked: 28
Current age: 44 Retire Age: 66 Number of years to be worked: 22
Current age: 55 Retire Age: 70 Number of years to be worked: 15
Current age: 19 Retire Age: 62 Number of years to be worked: 43
Current age: 35 Retire Age: 66 Number of years to be worked: 31
Current age: 44 Retire Age: 70 Number of years to be worked: 26
Current age: 32 Retire Age: 62 Number of years to be worked: 30

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