0

Shopping list error

I need a bit help how to fill in these methods. Any help would be appreciated guys. package week9; import java.util.ArrayList; import java.util.Scanner; public class ShoppingList1 { public static void main(String[] args) { Scanner sIn = new Scanner(System.in); ArrayList<String> shoppingList = new ArrayList<String>(); String choice; boolean done = false; do { // Print out the menu to the console System.out.println(); System.out.println("1. Add Items"); System.out.println("2. Delete Items"); System.out.println("3. Show Items"); System.out.println("4. Sort Items"); System.out.println("5. Exit"); System.out.print("Please enter a command: "); choice = sIn.nextLine(); switch (choice) { case "1": // Add items to the Shopping List System.out.println(addItems(sIn, shoppingList) + " items have been added to your Shopping List."); break; case "2": // Delete items from the Shopping List System.out .println(deleteItems(sIn, shoppingList) + " items have been deleted from your Shopping List."); break; case "3": // Show the items in the Shopping List showItems(shoppingList); break; case "4": // Sort the items in the Shopping List sortItems(shoppingList); break; case "5": // Exit the program System.out.println(); System.out.println("Goodbye"); done = true; break; default: // Handles all input that is not between 1-5 System.out.println("Invalid response. Please enter a choice from the menu (1-5)."); } // End of switch (choice) } while (!done); // Keep running the program until the user quits sIn.close(); }// end of main() public static int addItems(Scanner sIn, ArrayList<String> shoppingList) { return 0; }// end of method addItems(ArrayList<String>) public static int deleteItems(Scanner sIn, ArrayList<String> shoppingList) { return 0; }// end of method deleteItems(ArrayList<String>) public static

12th Nov 2022, 12:46 AM
gordon gabut
gordon gabut - avatar
1 Answer
+ 2
Please tag "java", not "javascript". Java and Javascript are different languages. Please link your complete code. Please do not paste the code into the description. – Go to Code section, click+, select the programming language, insert your code, save. – Come back to this thread, click +, Insert Code, sort for My Code Bits, select your code. Describe what the code is supposed to do.
12th Nov 2022, 10:55 AM
Lisa
Lisa - avatar