Question: For Java Continue building code from the one provided *Ask the user for items to add to a shopping list (store into an ArrayList) *Prompt

For Java

Continue building code from the one provided

*Ask the user for items to add to a shopping list (store into an ArrayList)

*Prompt the user for an item to search for on the list. Tell them whether or not it exists. (Dont just output true or false, write a message to the user)

*Prompt the user for an item to delete from the shopping list and remove it. (be sure to handle the case where they dont want to delete anything)

*Prompt the user for an item to insert into the list. Ask them what they want to insert and where they want to insert it (after which item).

*Output the final list to the user.

Code

import java.util.*;

import javax.swing.JOptionPane;

public class Assignment4Example

{

public static void main(String[] args)

{

String input;

ArrayList shopping = new ArrayList();

input = JOptionPane.showInputDialog("How many items will be in

the list?");

int numItems = Integer.parseInt(input);

for (int i = 0; i < numItems; i++)

{

input = JOptionPane.showInputDialog("Enter an

Item.");

shopping.add(input);

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!