Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use scnr to read each pair of inputs, integer currQuantity and string currFood, until - 9 9 9 is read from input. Create each Order

Use scnr to read each pair of inputs, integer currQuantity and string currFood, until -999 is read from input. Create each Order object with currQuantity and currFood as arguments and append each object to ArrayList orderList. 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;
int currQuantity;
String currFood;
int i;
/* Your code goes here */
for (i =0; i < orderList.size(); ++i){
currOrder = orderList.get(i);
currOrder.print();
}
}
} public class Order {
private int quantity;
private String food;
public void setQuantityAndFood(int newQuantity, String newFood){
quantity = newQuantity;
food = newFood;
}
public void print(){
System.out.println("Order quantity: "+ quantity +", Food: "+ food);
}
}

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What is meant by 'Wealth Maximization ' ?

Answered: 1 week ago