Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please type in C++: #include #include using namespace std; int main() { int numElements; string foodAsked; unsigned int i; cin >> numElements; vector foodList(numElements); vector

Please type in C++:

#include #include using namespace std;

int main() { int numElements; string foodAsked; unsigned int i;

cin >> numElements;

vector foodList(numElements); vector labelList(numElements);

for (i = 0; i > foodList.at(i); cin >> labelList.at(i); }

cin >> foodAsked;

/* Your code goes here */

return 0; }

image text in transcribed

Integer numElements is read from input. Then, strings and integers are read and stored into string vector foodList and integer vector labelList, respectively. Lastly, string foodAsked is read from input. Find foodAsked in foodList and output the following: - "The food " - the value of foodAsked - "has value" - the element in labelList at the index of foodAsked in foodList - " and is at index " - the index of foodAsked in foodList End with a newline. Ex: If the input is: 4 onion 16 guava 44 corn 89 cabbage 73 corn Then the output is: The food corn has value 89 and is at index 2 Note: foodAsked is an element in foodList

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions