Please help with insert code in the below java switch/case block of code, so it checks if the number combination already exist in the system, it don't need to be a proper SSN. For example if the user type in: 1234567890, for example a message coming up "the number already exist". Please answer with code example inserted in the code below and/or if the code maybe shall be in another class?switch (choice) { case 1 -> { System.out.print("Enter unique customer number: "); ssn = sc.nextInt(); System.out.print("Enter customer name: "); sc.nextLine(); String name = sc.nextLine(); Customer customer = new CustomerBuilder().setSsn(ssn).setName(name).createCustomer(); Bank.addCustomer(customer); System.out.println("\nCustomer added with unique number: " + customer.getSSN()); }
Please help with insert code in the below java switch/case block of code, so it checks if the number combination already exist in the system, it don't need to be a proper SSN. For example if the user type in: 1234567890, for example a message coming up "the number already exist". Please answer with code example inserted in the code below and/or if the code maybe shall be in another class?switch (choice) { case 1 -> { System.out.print("Enter unique customer number: "); ssn = sc.nextInt(); System.out.print("Enter customer name: "); sc.nextLine(); String name = sc.nextLine(); Customer customer = new CustomerBuilder().setSsn(ssn).setName(name).createCustomer(); Bank.addCustomer(customer); System.out.println("\nCustomer added with unique number: " + customer.getSSN()); }
Step by step
Solved in 2 steps