Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AakashCode12/befe8493dfdfe65466e3e4ff849acec6 to your computer and use it in GitHub Desktop.
Save AakashCode12/befe8493dfdfe65466e3e4ff849acec6 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Employee {
int empid;
String name;
float salary;
public void getInput() {
Scanner in = new Scanner(System.in);
System.out.print("Enter the empid :");
empid = in.nextInt();
System.out.print("Enter the name : ");
name = in.next();
System.out.print("Enter the salary : ");
salary = in.nextFloat();
System.out.println();
}
public void display() {
System.out.println("Employee id = " + empid);
System.out.println("Employee name = " + name);
System.out.println("Employee salary = " + salary);
}
public static void main(String[] args) {
Employee e[] = new Employee[2];
for(int i=0; i<2; i++) {
e[i] = new Employee();
e[i].getInput();
}
System.out.println("Data Entered as below");
for(int i=0; i<2; i++) {
e[i].display();
}
}
}
//C:\Program Files\Java\jdk-14.0.1\bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment