Problem Statement
Number-Guessing Game Assignment
Write a program for a number-guessing game. Each player will be given 10 attempts to key in a 4-digit number to guess the randomly generated number. All four digits of the computer-generated number MUST be different and the left-most digit cannot be zero. Create a menu that has 4 options as follows:

1)  To register number of participants and name
2)  To start the game 
3)  To show ranking
4)  To quit


The descriptions for the options are as below:

Option 1
User will be asked to key in the number of players (maximum 5 players) that challenge each other for top ranking. Their name will then be taken in one by one. Assume the names will not exceed 30 characters including spaces.

Option 2
When this option is chosen, the screen will be cleared and the first 4-digit random number generated will be displayed. This number is disclosed here for us to check whether the program is working correctly or not. It is not meant for the player to cheat. Once the number is shown, we will be asked to press any key to continue and the screen will be cleared so that the first player will not know the answer. Then, the first player will be called upon. The player needs to press any key to start the game. You need to do proper validations for the input numbers. The player will be asked to key in the number again if the input is not valid. Invalid inputs are not counted as an attempt. (none digit)
Each valid number which is input by the player will be analysed and a hint will be given (except for last attempt). The hint mentions how many digits are placed correctly (denoted by C), how many digits are not in the number at all (denoted by W), and how many digits are in the number but are positioned wrongly (denoted by P). For example, if the computer-generated number is 5314, the following shows some of the inputs and their respective hints.

1234    1C1W2P – 1 digit wrong,1 digit right position,2 digit right but position wrong
1435    0C0W4P – 4 digit right but position wrong
1354    2C0W2P – 2 digits wrong,2digits right but position wrong
3154    1C0W3P – 1 digit wrong, 3 digits right but position wrong
When the player successfully guesses the number, a congratulatory message is shown to tell player how many attempts had been made to guess the number. If player doesn’t get the number within 10 attempts, a sorry message is shown.

When first player’s game is over, the screen will be cleared after pressing a key. The computer will then generate another new 4-digit number for the second player and reveal it before it is cleared. Then the second player will be called upon and the process continues until the last player.

Option 3
The players will be ranked according to their number of attempts used to guess the number. Player with the least attempts ranked the top. If two players have the same number of attempts, the one who used less time wins. So, you also need to time each player during their game besides recording the number of attempts.

Option 4
When this option is chosen, display “Bye!” and end the program.

Note
-   For time, use difftime(time_t, time_t) function and include <ctime> header
-   For random number, use rand() and include <cstdlib> header

the example output:

2.png3.png4.png5.png6.png7.png ![1.png](/attachments/small/4/9bd4ea064ba15661824b7db3e29f9046.png "align-left")8.png9.png10.png11.png12.png13.png

No one is going to write the code for you. If write some code youself and you have an issue with it then post the code you have and what the issue is. also include any sample data and expected output. See http://sscce.org for more on writing a good code question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.