Integer inputSize is read from input. Then, integers and strings are read and stored into integer vector quantityList and string vector foodList, respectively. Lastly, integer quantityAsked is read from input. Find quantityAsked in quantityList and output the following: • The quantity" • the value of quantityAsked . *is matched with food" the element in foodList at the index of quantityAsked in quantityList *and is at index" the index of quantityAsked in quantityList End with a newline. Ex: If the input is: 4 44 lettuce 48 chicken 59 guava 40 pineapple 48 Then the output is: The quantity 48 is matched with food chicken and is at index 1
Integer inputSize is read from input. Then, integers and strings are read and stored into integer vector quantityList and string vector foodList, respectively. Lastly, integer quantityAsked is read from input. Find quantityAsked in quantityList and output the following: • The quantity" • the value of quantityAsked . *is matched with food" the element in foodList at the index of quantityAsked in quantityList *and is at index" the index of quantityAsked in quantityList End with a newline. Ex: If the input is: 4 44 lettuce 48 chicken 59 guava 40 pineapple 48 Then the output is: The quantity 48 is matched with food chicken and is at index 1
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
Step 1
Algorithm:
1. Start
2. Declare an integer variable inputSize, an integer variable quantityAsked, and an unsigned integer variable i.
3. Read the size of the input and store it in input size.
4. Declare a vector quantity list of size inputs.
5. Declare a vector food list of size inputs.
6. For i = 0 to inputSize - 1, read in the quantity and food name and store it in quantityList and foodList respectively.
7. Read in the quantity asked and store it in quantityAsked.
8. For i = 0 to input size - 1, check if the quantity in the quantity list at index i is equal to the quantity asked.
9. If yes, print out the food at index i in foodList, index, and break the loop.
10. End.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education