Question: Repeat the following until currPurchase's readDetails ( ) method returns false: Assign currPurchase with a new Purchase object. Use currPurchase's readDetails ( ) method to

Repeat the following until currPurchase's readDetails() method returns false:
Assign currPurchase with a new Purchase object.
Use currPurchase's readDetails() method to read each pair of inputs, character option and string food.
If currPurchase's readDetails() method returns true, append currPurchase to ArrayList purchaseList.
Ex: If the input is D plantain A citron C chayote %, then the output is:
Purchase option: D, Food: plantain
Purchase option: A, Food: citron
Purchase option: C, Food: chayote
import java.util.Scanner;
import java.util.ArrayList;
public class Purchases {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
ArrayList purchaseList = new ArrayList();
Purchase currPurchase;
boolean result;
int i;
/* Your code goes here */
for (i =0; i < purchaseList.size(); ++i){
currPurchase = purchaseList.get(i);
currPurchase.print();
}
}
}

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 Programming Questions!