import java.util.*; import java.lang.Exception; class Salary{
// initializing The Variables
int emp; int[] eId = new int[100]; int[] sal = new int[100]; String[] eName = new String[100]; int[] esal = new int[100]; int[] Nday = new int[100];
// Getting data from user
public void Salary() { Scanner sc = new Scanner(System.in); System.out.println("Enter the Number of Employee in Your Company: "); emp = sc.nextInt(); for (int i = 1; i <= emp; i++) { System.out.println("Enter Id of Employee "+i+" : "); eId[i] = sc.nextInt(); System.out.println("Enter Name of Employee " + i + " :"); eName[i] = sc.next(); System.out.println("Enter The Salary of Employee(per day) " + i + " :"); esal[i] = sc.nextInt(); System.out.println("Enter No of days he worked: "); Nday[i] = sc.nextInt(); sal[i] = esal[i]*Nday[i]; } sc.close(); }
// Displaying the data void Display(){ Formatter fmt = new Formatter(); fmt.format("\n%10s%20s%20s\n\n","S No.","Name","Salary"); for (int j = 1; j <= emp; j++) { fmt.format("%10s%20s%20s\n",eId[j],eName[j],sal[j]); } System.out.println(fmt); System.out.println("\n Thanking You..."); } } public class p41_EmpSalary { public static void main(String[] args) throws Exception { Salary s = new Salary(); s.Salary(); s.Display(); } }