need help with Java Please!!!
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 column of the array.
Maybe this will help with the first part: http://stackoverflow.com/questions/12231453/syntax-for-creating-a-two-dimensional-array The first response seems reliable, but I don't know this language. Best of luck on your program!
public static void main(String[] args){ Scanner scan = new Scanner(System.in); String currentAge[] = new String[10]; for (int i = 0; i < 11; i++) { System.out.print("Enter the current age " + (i+1) + " : "); currentAge[i] = scan.nextLine(); } for (int i = 0; i < 11; i++) { System.out.print("Current Age " + (i+1) + " : "); System.out.print(Current Age[i] + "\n"); } } This is for inputting the current age and displaying it as an array, you do similar loop for the retirement age but make sure you put both in the same array as that's what they are asking for. Cheers :)
thanks
What's slack
what?
Join our real-time social learning platform and learn together with your friends!