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 mainString args
Scanner scnr new ScannerSystemin;
ArrayList purchaseList new ArrayList;
Purchase currPurchase;
boolean result;
int i;
Your code goes here
for i ; i purchaseList.size; i
currPurchase purchaseList.geti;
currPurchase.print;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
