Question: 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

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!