Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I must use following parallel vectors: vector<int> hours; vector<int> rate; and

ID: 3614728 • Letter: I

Question

I must use following parallel vectors:
vector<int> hours;
vector<int> rate;
and function prototype:
void printResult (vectory<int> vec 2, vector<int> vec3,int num);

step 1:
Must use push_back member function to insert following values:
hours: 40 35 40 30 40
rate: 15 20 18 17 20
after loading vectors using push_back function, must callprintResult to output the product "hours * rate" for each parallelmember.

step 2:
in the vector hours, change the values: 35 to 40 and 30 to 20 andrepeat the call to function printResult

Explanation / Answer

#include<iostream>
#include <vector>
using namespace std;
vector<int> hours;
vector<int> rate;
void printResult (vector<int> vec2, vector<int> vec3,int num)
{
     int i;
     cout<<endl;
     for(i=0;i<num;i++)
     cout<<vec2[i]<<" x"<<vec3[i]<<" ="<<vec2[i]*vec3[i]<<endl;
}
int main()
{
hours.push_back(40);
hours.push_back(35);
hours.push_back(40);
hours.push_back(30);
hours.push_back(40);
rate.push_back(15);
rate.push_back(20);
rate.push_back(18);
rate.push_back(17);
rate.push_back(20);

printResult(hours,rate,5);
hours[1]=40;
hours[3]=20;
cout<<endl<<"After replacing vector is :";
printResult(hours,rate,5);

system("pause");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote