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 0.
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 =0; i < inputSize; ++i){
cin >> stringVal;
cin >> intVal;
furnitureList.push_back(stringVal);
quantityList.push_back(intVal);
}
cin >> furnitureAsked;
/* Your code goes here */
cout << "Total: "<< sumQuantity << endl;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!