Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use scnr to read each pair of inputs, string currFood and integer currQuantity, until end is read from input. Create each Order object with currFood
Use scnr to read each pair of inputs, string currFood and integer currQuantity, until "end" is read from input. Create each Order object with currFood and currQuantity as arguments and append each object to ArrayList orderList.
Ex: If the input is sausage carrot pineapple eggplant end, then the output is:
Order: sausage, Quantity:
Order: carrot, Quantity:
Order: pineapple, Quantity:
Order: eggplant, Quantity: import java.util.Scanner;
import java.util.ArrayList;
public class Orders
public static void mainString args
Scanner scnr new ScannerSystemin;
ArrayList orderList new ArrayList;
Order currOrder;
String currFood;
int currQuantity;
int i;
your code goes here
for i ; i orderList.size; i
currOrder orderList.geti;
currOrder.print;
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