Answered step by step
Verified Expert Solution
Link Copied!

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 15 carrot 5 pineapple 25 eggplant 20 end, then the output is:
Order: sausage, Quantity: 15
Order: carrot, Quantity: 5
Order: pineapple, Quantity: 25
Order: eggplant, Quantity: 20 import java.util.Scanner;
import java.util.ArrayList;
public class Orders {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
ArrayList orderList = new ArrayList();
Order currOrder;
String currFood;
int currQuantity;
int i;
your code goes here
for (i =0; i < orderList.size(); ++i){
currOrder = orderList.get(i);
currOrder.print();
}
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

define a process path

Answered: 1 week ago

Question

When would you use one approach, and when would you use another?

Answered: 1 week ago