عبد الرحمن صالح المغيصيب
unknown
java
2 years ago
1.3 kB
3
Indexable
import java.util.*; public class JavaApplication2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("enter the number of emplyees for all departments"); int x= in.nextInt();// input is 3 int arr[][]= new int[3][x]; int sum=0; int avg=0; int last=0; String details="\t\temployee information\t\t\n"; for(int i=0;i<3;i++){ for(int j =0;j<x;j++) { System.out.println("enter age of employee number "+(j+1)+" department number "+(i+1)); arr[j][i]= in.nextInt(); if (arr[j][i]<1||arr[j][i]>59){ System.out.println("employee age should be bigger than 1 and lower than 59 please try again"); j--;} else {details+=("employee number "+(j+1)+" age is : "+arr[j][i]+" what is left of his service is :"+(60-arr[j][i])+"\n"); sum+=arr[j][i];} } details+="\n"+x+" is the number of employees in department number "+(i+1)+" the summation of their age is : "+sum+" the average of their age is "+(sum/3)+"\n"; details+="\n---------------------------------------------------------------------------\n"; sum=0; } System.out.println(details); } }
Editor is loading...