Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 9: PART A: #include #include using namespace std; int main() { int numElements; string inventoryAsked; int sumQuantity; unsigned int i; cin >> numElements; vector

QUESTION 9:

PART A:

image text in transcribed

#include #include using namespace std;

int main() { int numElements; string inventoryAsked; int sumQuantity; unsigned int i; cin >> numElements;

vector inventoryList(numElements); vector quantityList(numElements);

for (i = 0; i > inventoryList.at(i); cin >> quantityList.at(i); }

cin >> inventoryAsked;

// ENTER THE MISSING PIECE OF CODE HERE AND TEST IT IN C++. DO NOT MODIFY THE REST OF THE CODE. (THANK YOU) cout

return 0; }

----------------

PART B:

image text in transcribed

#include using namespace std;

class TimeCard { public: TimeCard(int hoursWorked = 0, int hoursOff = 0); void Print() const; TimeCard operator+(TimeCard rhs); private: int workingHours; int vacationHours; };

TimeCard::TimeCard(int hoursWorked, int hoursOff) { workingHours = hoursWorked; vacationHours = hoursOff; }

// No need to accommodate for overflow or negative values

// ENTER THE MISSING PIECE OF CODE HERE AND TEST IT IN C++. DO NOT MODIFY THE REST OF THE CODE. (THANK YOU)

void TimeCard::Print() const { cout

int main() { int hoursWorked1; int hoursOff1; int hoursWorked2; int hoursOff2; cin >> hoursWorked1; cin >> hoursOff1; cin >> hoursWorked2; cin >> hoursOff2; TimeCard timeCard1(hoursWorked1, hoursOff1); TimeCard timeCard2(hoursWorked2, hoursOff2); TimeCard sum = timeCard1 + timeCard2; timeCard1.Print(); cout

----------

Thank you! >:D

Integer numElements is read from input. Then, strings and integers are read and stored into string vector inventoryList and integer vector quantityList, respectively. Lastly, string inventoryAsked is read from input. - Find the sum of the elements in quantityList where the corresponding element in inventoryList is equal to inventoryAsked. - For each element in inventoryList that is equal to inventoryAsked, output "Index " followed by the element's index. End with a newline. Ex: If the input is: 4 dresser 66 cradle 203 dresser 64 dresser 64 dresser Then the output is: Index 0 Index 2 Index 3 Total: 194 Four integers are read from input, where the first two integers are the working hours and vacation hours of timeCard1 and the second two integers are the working hours and vacation hours of timeCard2. Define the function to overload the + operator. Ex: If the input is 141387 , then the output is: 14 working hours, 13 vacation hours 8 working hours, 7 vacation hours Sum: 22 working hours, 20 vacation hours Note: The sum of two time cards is: - the sum of the number of working hours - the sum of the number of vacation hours

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Mastering Apache Cassandra 3 X An Expert Guide To Improving Database Scalability And Availability Without Compromising Performance

Authors: Aaron Ploetz ,Tejaswi Malepati ,Nishant Neeraj

3rd Edition

1789131499, 978-1789131499

Students also viewed these Databases questions