fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. table add = new table();
  13. add.table();
  14. }
  15. }
  16. class table {
  17.  
  18. public void table() {
  19. addClass add = new addClass();
  20. add.addClass();
  21. System.out.println("********************************************************");
  22. System.out.println("ID \t\t\t NAME");
  23.  
  24. if (add.getEmployeeName1() == null) {
  25. System.out.println("---");
  26. } else {
  27. System.out.println("1" + "\t\t\t" + add.getEmployeeName1());
  28. }
  29. }
  30. }
  31.  
  32. class addClass {
  33.  
  34. String employeeName;
  35.  
  36. public void addClass() {
  37. Scanner input = new Scanner(System.in);
  38. System.out.println("****************************************");
  39. System.out.println("EMPLOYEE SALARY INFORMATION SYSTEM - ADD");
  40. System.out.println("**************************************** \n");
  41. System.out.println("Enter ID number (1-10): ");
  42. int id_number = input.nextInt();
  43. switch (id_number) {
  44. case 1:
  45. System.out.print("Employee Name: ");
  46. input.nextLine();
  47. setEmployeeName1(input.nextLine());
  48. break;
  49. }
  50. }
  51.  
  52. public void setEmployeeName1(String newEmployeeName1) {
  53. this.employeeName = newEmployeeName1;
  54. }
  55.  
  56. public String getEmployeeName1() {
  57. return employeeName;
  58. }
  59. }
Success #stdin #stdout 0.07s 2184192KB
stdin
1
Joe Bloggs
stdout
****************************************
EMPLOYEE SALARY INFORMATION SYSTEM - ADD
**************************************** 

Enter ID number (1-10): 
Employee Name: ********************************************************
ID 			 NAME
1			Joe Bloggs