Advertisement
selvalives

Untitled

Dec 9th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Executer
  3. {
  4. public static void main(String[] args)
  5. {
  6. int ctr=0;
  7. Customer c[]=new Customer[10];
  8. for(;;)
  9. {
  10. int choice;
  11. System.out.println("Welcome");
  12. System.out.println("Current Customers Count :" +ctr);
  13. menu();
  14. Scanner scanner=new Scanner(System.in);
  15. choice=Integer.parseInt(scanner.nextLine());
  16. if(choice==1)
  17. {
  18. c[ctr]=new Customer();
  19. System.out.println("Enter FirstName");
  20. c[ctr].setFirstName(scanner.nextLine());
  21. System.out.println("Enter LastName");
  22. c[ctr].setLastName(scanner.nextLine());
  23. System.out.println("Enter CustomerID");
  24. c[ctr].setCustomerID(scanner.nextLine());
  25. ctr++;
  26. }
  27. else if(choice==2)
  28. {
  29. String search;
  30. System.out.println("Enter CustomerID");
  31. search=scanner.nextLine();
  32. for(int k=0;k<ctr;k++)
  33. {
  34. if(search.equals(c[k].getCustomerID()))
  35. {
  36. System.out.println("Found");
  37. System.out.println("Enter New FirstName");
  38. c[k].setFirstName(scanner.nextLine());
  39. System.out.println("Enter New LastName");
  40. c[k].setLastName(scanner.nextLine());
  41. System.out.println("Updated");
  42. break;
  43. }
  44. }
  45. }
  46. else if(choice==3)
  47. {
  48. String search;
  49. System.out.println("Enter CustomerID");
  50. search=scanner.nextLine();
  51. for(int k=0;k<ctr;k++)
  52. {
  53. if(search.equals(c[k].getCustomerID()))
  54. {
  55. System.out.println("Found");
  56. System.out.println(c[k].getFirstName()+","+c[k].getLastName()+","+c[k].getCustomerID());
  57. break;
  58. }
  59. }
  60. }
  61. else if(choice==4)
  62. {
  63.  
  64. for(int k=0;k<ctr;k++)
  65. {
  66. System.out.println(c[k].getFirstName()+","+c[k].getLastName()+c[k].getCustomerID());
  67. }
  68. }
  69. }
  70. }
  71. public static void menu()
  72. {
  73. System.out.println("Welcome");
  74. System.out.println("1. Add Customer");
  75. System.out.println("2. Edit Customer");
  76. System.out.println("3. Search Customer");
  77. System.out.println("4. List Customers");
  78. System.out.println("Enter your choice");
  79. }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement