## Description

PS4

Deadline: Tuesday midnight 11:55pm (before the next PS)

• Don’t wait till the last moment.

Q1

You operate several hot dog stands distributed throughout town. Definite a class named HotDogStand that has a member

variable for the hot dog stand’s ID number and a member variable for how many hot dogs the stand has sold that day.

Create a constructor that allows a user of the class to initialize both values.

Also create a method named “JustSold” that increments the number of hot dogs the stand has sold by one. The idea is

that this method will be invoked each time the stand sells a hot dog so that we can track the total number of hot dogs sold

by the stand. Add another method that returns the number of hot dogs sold.

Finally, add a static variable that tracks the total number of hotdogs sold by all hot dog stands and a static method that

returns the value in this variable.

Write a main method to test your class with at least three hot dog stands that each sell a variety of hot dogs.

CodeMate Hint: Recall that static variables must be initialized outside of the class definition.

Q2

In an ancient land, the beautiful princess Eve had many suitors. She decided on the following procedure to determine

which suitor she would marry. First, all of the suitors would be lined up one after the other and assigned numbers. The

first suitor would be number 1, the second number 2, and so on up to the last suitor, number n. Starting at the first suitor

she would then count three suitors down the line (because of the three letters in her name) and the third suitor would be

eliminated from winning her hand and removed from the line. Eve would then continue, counting three more suitors, and

eliminating every third suitor. When she reached the end of the line she would continue counting from the beginning.

For example, if there were 6 suitors then the elimination process would proceed as follows:

123456 initial list of suitors, start counting from 1

12456 suitor 3 eliminated, continue counting from 4

1245 suitor 6 eliminated, continue counting from 1

125 suitor 4 eliminated, continue counting from 5

15 suitor 2 eliminated, continue counting from 5

1 suitor 5 eliminated, 1 is the lucky winner

Write a program that uses a vector to determine which position you should stand in to marry the princess if there are n

suitors. You will find the following method from the Vector class useful:

v.erase(iter);

// Removes element at position iter

For example, to use this method to erase the 4th element from the beginning of a vector variable named theVector use:

theVector.erase(theVector.begin() + 3);

The number 3 is used since the first element in the vector is at index position 0.

CodeMate Hint: Use a vector of size n and a loop that continues to eliminate the next suitor until the size of the vector

includes only one element.

Turn In

• Make and submit a zip file(<your_full_name>_PS4.zip) which includes the following:

– Source code of Q1: q1.cpp

– Source code of Q2: q2.cpp

1

– Run Q1 and Q2 and attach screenshots(in jpg format, not exceeding 300kb each) which show that your programs

are running.

– At least 1 screenshot for each question.

2