Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Explain the code below #will rate highly need asap import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new

Explain the code below #will rate highly need asap import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Process process = new Process(); // create instance of Process class Customer customer = null; String id; String name; String stall; String product; String lot; int role; while(true){ System.out.println("Enter Role: 1. Admin 2. User"); role = scan.nextInt(); scan.nextLine(); if(role == 1){ System.out.println("Enter username :"); String username = scan.nextLine(); System.out.println("Enter password :"); String password = scan.nextLine(); if(username.equals("admin") && password.equals("1234")) { while (true) { ArrayList arrayList = new ArrayList<>(); System.out.println(" ===================================================="); System.out.println(" Thai Festival Booth System "); System.out.println("===================================================="); System.out.println("[1] Add New Seller Details"); System.out.println("[2] Delete Seller Details"); System.out.println("[3] Update Seller Details"); System.out.println("[4] View Seller Details"); System.out.println("[5] Quit Program"); System.out.println("===================================================="); System.out.print("Select a Number : "); int select = scan.nextInt(); scan.nextLine(); if (select == 1) { System.out.print("Enter Licience ID: "); id = scan.next(); while(process.isIdExist(id) != false) { System.out.println("Error! Cannot Same ID!"); System.out.print("Enter Licience ID: "); id = scan.next(); } System.out.print("Enter Licience Name: "); name = scan.next(); System.out.print("Enter Stall Name: "); stall = scan.next(); System.out.print("Enter Product: "); product = scan.next(); System.out.print("Enter Lot Number: "); lot = scan.next(); while(Integer.parseInt(lot) >= 25) { System.out.println("Error! Lot number must be less than 25!"); System.out.print("Enter Lot Number: "); lot = scan.next(); } scan.nextLine(); System.out.print("Enter customer phone number :"); String phoneNumber = scan.nextLine(); System.out.print("Enter customer address:"); String address = scan.nextLine(); customer = new Customer(id, name, stall, product, lot, address,phoneNumber); process.addDetails(customer); } else if (select == 2) { System.out.println("Enter id to be removed :"); id = scan.nextLine(); process.deleteDetail(id); process.deleteFile(id); } else if (select == 3) { System.out.println("Enter id to be updated :"); id = scan.nextLine(); System.out.println("Enter what to update:"); System.out.println("1. ID"); System.out.println("2. Name"); System.out.println("3. Stall"); System.out.println("4. Product"); System.out.println("5. Lot"); System.out.println("6. Address"); System.out.println("7. Phone Number"); int update = scan.nextInt(); scan.nextLine(); System.out.println("What do you want to replace it with?"); String newUpdate = scan.nextLine(); process.updateDetail(id, update, newUpdate); } else if (select == 4) { System.out.println("Enter ID you want to find"); id = scan.nextLine(); process.viewDetails(id); } else if (select == 5) { break; } } } } else if(role == 2){ System.out.println("Enter license ID"); id = scan.nextLine(); System.out.println(""); System.out.println(" Booth Diagram "); System.out.println("[LOT 1 ] [LOT 2 ] [LOT 3 ] [LOT 4 ] [LOT 5 ]"); System.out.println(""); System.out.println("[LOT 6 ] [LOT 7 ] [LOT 8 ] [LOT 9 ] [LOT 10]"); System.out.println(""); System.out.println("[LOT 11] [LOT 12] [LOT 13] [LOT 14] [LOT 15]"); System.out.println(""); System.out.println("[LOT 16] [LOT 17] [LOT 18] [LOT 19] [LOT 20]"); System.out.println(""); System.out.println("[LOT 21] [LOT 22] [LOT 23] [LOT 24] [LOT 25]"); System.out.println(""); process.fileFinder(id); } else if( role == 3) { break; } else { System.out.println("Invalid Role"); } } } }                        
                                            
                    

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions