ECE3400 (Assignment 1) Hangman Game solution


Original Work


5/5 - (4 votes)

You are to write a program in C++ which simulates the playing of the game Hangman. I plan to cover any remaining programming topics needed to solve this assignment in class on Friday, September 17.

Your program should accept input from standard input (std::cin or cin) as follows:

The first line that it accepts should be a string of uppercase English characters. If the string does not conform to this specification, the program should simply exit.

Then subsequent lines should each only consist of a single uppercase English character followed by a new line (which can be input by pressing the ‘Enter’ key). If the line does not conform to this format, then the program should exit immediately.

The program should allow for single uppercase English letters to be input until all letters appearing in the initial word have been entered. In that case, the program should output to standard output (std::cout or cout) a string on a new line simply saying:


There should be a newline character after the final exclamation mark in this output message. After this message has been output, the program should exit.

You are to do this assignment individually. You may also write test code for your program if you wish, before the autograder becomes ready in the next few days. It is permitted for test code to be written by more than one person and shared amongst students in the course. There will also be 3 marks out of the total 10 marks allocated for coding style.