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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started