Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program first reads integer purchaseCount from input, representing the number of pairs of inputs to be read. Each pair has a string and an

The program first reads integer purchaseCount from input, representing the number of pairs of inputs to be read. Each pair has a string and an integer, representing the purchase's food and quantity, respectively. One Purchase object is created for each pair and added to ArrayList purchaseList. If a Purchase object's quantity is between 4 and 20, both inclusive, call the Purchase object's print() method.
Ex: If the input is:
4
daikon 4 truffle 30 celery 20 plantain 21
then the output is:
Purchase: daikon, Quantity: 4
Purchase: celery, Quantity: 20

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

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions