Question: Integer inputSize is read from input. Then, inputSize pairs of strings and integers are read and stored into string vector furnitureList and integer vector quantityList,
Integer inputSize is read from input. Then, inputSize pairs of strings and integers are read and stored into string vector furnitureList and integer vector quantityList, respectively. Lastly, string furnitureAsked is read from input. Complete the following tasks:
Initialize sumQuantity with
Use a loop to find the sum of the elements in quantityList where the corresponding element in furnitureList is equal to furnitureAsked. For each element in furnitureList that is equal to furnitureAsked, output "Index followed by the element's index. End with a newline.
vector quantityList;
int inputSize;
string furnitureAsked;
int sumQuantity;
unsigned int i;
string stringVal;
int intVal;
cin inputSize;
for i ; i inputSize; i
cin stringVal;
cin intVal;
furnitureList.pushbackstringVal;
quantityList.pushbackintVal;
cin furnitureAsked;
Your code goes here
cout "Total: sumQuantity endl;
return ;
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
