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

Modify HW05 to use signals to pause the output of the timer instead of control c

ID: 3794491 • Letter: M

Question

Modify HW05 to use signals to pause the output of the timer instead of control characters. So, the only terminal setting you will need to modify programatically is echoing. If the user hits ctrl-C, the program pauses. If they hit it again, it unpauses. Ctrl- terminates and restores the settings gracefully.

Hints :

Spinlocks :

while( pause == true)
{}

If pause is set to true, then this while loop will iterate. When pause gets set to false, this loop gets skipped.

See the attached code for a spinlock example, spinlock.cpp

Spinlock.cpp

HW5

Explanation / Answer

reset game;

roll two dice and sum;

increment number of rolls;

point = sum;

if (point was a 7 or 11)

game is won;

else if (point is not 2, not 3 and not 12) {

do {

roll two dice and sum;

increment number of rolls;

value = sum;

} while (value is not point or is 7);

if (value is point)

   game is won;

else

      game is lost;

}

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