Question: How do I fix this code so that display all customers includes new added customers and fix the error so that it can search a

How do I fix this code so that display all customers includes new added customers and fix the error so that it can search a five number customer ID without error

 import java.util.Scanner; public class Main { public static String ArrayNames[] = new String[100]; public static int ArrayId[] = new int[100]; public static int ArraySales[] = new int[100]; public static boolean a = true; public static void main(String [] args){ Instructions(); while (a){ Instructions(); } } public static int Instructions(){ System.out.println("Enter 1 to Load Instructions"); System.out.println("Enter 2 to Load Data"); System.out.println("Enter 3 to Add new Customers"); System.out.println("Enter 4 to Display All Customers"); System.out.println("Enter 5 to Retrieve Specific Customers Data"); System.out.println("Enter 6 to Retrieve Customers with Total Sales based on Range"); System.out.println("Enter 7 to exit"); Scanner ScannerInput = new Scanner(System.in); int Selection = ScannerInput.nextInt(); switch (Selection){ case 1: Instructions(); break; case 2: LoadData(); break; case 3: AddNewCustomer(); break; case 4: DisplayData(); break; case 5: RetrieveCustData(); break; case 6: RetrieveInfoOnRange(); break; case 7: a=false; break; } return Selection; } public static void LoadData(){ System.out.println("Enter the number of customers to be loaded"); Scanner ScannerInput1 = new Scanner(System.in); int NoOfCust = ScannerInput1.nextInt(); for (int i = 0;i=Lowest_Sales && ArraySales[a]<=HighestSales){ System.out.println(ArrayId[a] + ArrayNames[a] + ArraySales[a]); } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Displaying all customers Instead of using a fixedsize array you should use a dynamic data structure like ArrayList to store customer data This allows adding new customers without worrying about the ar... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!