Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part A. Write pseudocode for the game of mastermind Part B. Draw a flowchart for the pseudocode you just wrote Part C. C program. Based

Part A. Write pseudocode for the game of mastermind

Part B. Draw a flowchart for the pseudocode you just wrote

Part C. C program. Based on the flowchart and pseudocode youve designed on the previous step, now we are going to provide the skeleton of the C program for the Mastermind game.image text in transcribedimage text in transcribedimage text in transcribed

In the simple, text-version of Mastermind game that we are going to develop, instead of colors we simply use digits 1 to 9. Therefore, codemaker (Computer) will randomly selects four unique, non- duplicated, digits and then codebreaker will start guessing the four digits. If the codebreaker guesses the correct code in less then or equal to ten guesses, s/he wins and otherwise loses. Then, the codebreaker has the opportunity to play again or just exit from the game. In each step of the game, proper message should be provided by the codemake (computer) to the codebreaker. For instance, at the beginning there would be a welcome message, followed by asking the codebreaker to guess the code. After each guess, an accurate feedback should be shown to the codebreaker. If codebreaker wins/loses, proper message showed be shown to the codebreaker as well. You can get some ideas from the sample execution of the program on page 4 of this document. Part B: Pseudocode: (40 marks) Using the above game rules, write the pseudocode (formal or informal) for the Mastermind game. As a hint, we start it as follows, and you should complete it: 1. Start 2. Show a Welcome message to the player. 3. Generate a random code. ... Complete the next steps 4. X. Ask the player if they want to play again or not a. If yes, go to step 3 5. X. Ask the player if they want to play again or not a. If yes, go to step 3 b. If no, show a Goodbye message and end the program X+1. End Part C: Flowchart (40 marks) Using the pseudocode you wrote in the previous part, draw a flowchart for the Mastermind game. | You can use any flowchart software, like Raptor, or simply draw it on any software with graphical capabilities, like Word, Excel, PowerPoint, Paintbrush, etc. Part D: C program (20 marks) | Based on the flowchart and pseudocode you've designed on the previous step, now we are going to provide the skeleton of the C program for the Mastermind game. Your task in this part is to just start writing a C program with the following parts: Include required standard libraries Show a welcome message to the player Write COMMENTS for the major steps of the code based on the flowchart you have prepared. Like in any programming language, in C programs you can add comments on any part of your code. Comments are not executable but will help the reader to understand the code. Note that you don't have to write any actual code that we haven't learned yet in this assignment. Hint: There are two ways to have comments inside a C program: 1. In-line comment: type // and then write the comment. The rest of the line after // will be considered as comments and not the actual program code Example: #include // c Standard Library for input/output functions 2. Multi-line comment: type /* and start writing your comment on one or more lines. At the end, finish the comments by typing */ Example: /* This program implements the Mastermind game, in which a player can play Terminal 3 O src (Saeeds-MacBook-Pro.local) 3 bash-3.25 ./MasterMind Welcome to MasterMind Gamne!!! Version 4 Release Date: Jan. 10, 2020 Programmer: Saeed Samet. **** You have 10 remaining chance(s). Guess 4 numbers (enter e to exit): 123 4 Correct Location & Number : 0, Correct Number : 2 You have 9 remaining chance(s). Guess 4 numbers (enter e to exit): 5126 Correct Location & Number : 0, Correct Number : 1 You have 8 remaining chance(s). Guess 4 numbers (enter e to exit): 7346 Correct Location & Number : 0, Correct Number : 4 You have 7 remaining chance(s). Guess 4 numbers (enter e to exit): 3 4 67 Correct Location & Number : 1, Correct Number : 3 You have 6 remaining chance(s). Guess 4 numbers (enter e to exit): 6 47 3 Correct Location & Number : 4, Correct Number : 0 Excellent!!! you solved it with 5 guesses, in 96 seconds. Do you want to play another game? (No:0, Yes:1)1 **** You have 10 remaining chance(s). Guess 4 numbers (enter 0 to exit): 1 11 1 Correct Location & Number : 0, Correct Number : e You have 9 remaining chance(s). Guess 4 numbers (enter 0 to exit): 2 222 Correct Location & Number : 0, Correct Number : e You have 8 remaining chance(s). Guess 4 numbers (enter 0 to exit): 3 333 Correct Location & Number : 0, Correct Number : 0 You have 7 remaining chance(s). Guess 4 numbers (enter 0 to exit): 4 4 4 4 Correct Location & Number : 0, Correct Number : 0 You have 6 remaining chance(s). Guess 4 numbers (enter 0 to exit): 5555 Correct Location & Number : 1, Correct Number : e You have 5 remaining chance(s). Guess 4 numbers (enter 0 to exit): 6 6 6 6 Correct Location & Number : 1, Correct Number : e You have 4 remaining chance(s). Guess 4 numbers (enter 0 to exit): 7 777 Correct Location & Number : 1, Correct Number : e You have 3 remaining chance(s). Guess 4 numbers (enter 0 to exit): 8 8 88 Correct Location & Number : 1, Correct Number : e You have 2 remaining chance(s). Guess 4 numbers (enter 0 to exit): 5 67 8 Correct Location & Number : 2, Correct Number : 2 You have 1 remaining chance(s). Guess 4 numbers (enter 0 to exit): 5 6 87 Correct Location & Number : 1, Correct Number : 3 Sorry, You Lost :( Answer is:7 6 5 8 Do you want to play another game? (No:0, Yes:1)0 bash-3.2$ In the simple, text-version of Mastermind game that we are going to develop, instead of colors we simply use digits 1 to 9. Therefore, codemaker (Computer) will randomly selects four unique, non- duplicated, digits and then codebreaker will start guessing the four digits. If the codebreaker guesses the correct code in less then or equal to ten guesses, s/he wins and otherwise loses. Then, the codebreaker has the opportunity to play again or just exit from the game. In each step of the game, proper message should be provided by the codemake (computer) to the codebreaker. For instance, at the beginning there would be a welcome message, followed by asking the codebreaker to guess the code. After each guess, an accurate feedback should be shown to the codebreaker. If codebreaker wins/loses, proper message showed be shown to the codebreaker as well. You can get some ideas from the sample execution of the program on page 4 of this document. Part B: Pseudocode: (40 marks) Using the above game rules, write the pseudocode (formal or informal) for the Mastermind game. As a hint, we start it as follows, and you should complete it: 1. Start 2. Show a Welcome message to the player. 3. Generate a random code. ... Complete the next steps 4. X. Ask the player if they want to play again or not a. If yes, go to step 3 5. X. Ask the player if they want to play again or not a. If yes, go to step 3 b. If no, show a Goodbye message and end the program X+1. End Part C: Flowchart (40 marks) Using the pseudocode you wrote in the previous part, draw a flowchart for the Mastermind game. | You can use any flowchart software, like Raptor, or simply draw it on any software with graphical capabilities, like Word, Excel, PowerPoint, Paintbrush, etc. Part D: C program (20 marks) | Based on the flowchart and pseudocode you've designed on the previous step, now we are going to provide the skeleton of the C program for the Mastermind game. Your task in this part is to just start writing a C program with the following parts: Include required standard libraries Show a welcome message to the player Write COMMENTS for the major steps of the code based on the flowchart you have prepared. Like in any programming language, in C programs you can add comments on any part of your code. Comments are not executable but will help the reader to understand the code. Note that you don't have to write any actual code that we haven't learned yet in this assignment. Hint: There are two ways to have comments inside a C program: 1. In-line comment: type // and then write the comment. The rest of the line after // will be considered as comments and not the actual program code Example: #include // c Standard Library for input/output functions 2. Multi-line comment: type /* and start writing your comment on one or more lines. At the end, finish the comments by typing */ Example: /* This program implements the Mastermind game, in which a player can play Terminal 3 O src (Saeeds-MacBook-Pro.local) 3 bash-3.25 ./MasterMind Welcome to MasterMind Gamne!!! Version 4 Release Date: Jan. 10, 2020 Programmer: Saeed Samet. **** You have 10 remaining chance(s). Guess 4 numbers (enter e to exit): 123 4 Correct Location & Number : 0, Correct Number : 2 You have 9 remaining chance(s). Guess 4 numbers (enter e to exit): 5126 Correct Location & Number : 0, Correct Number : 1 You have 8 remaining chance(s). Guess 4 numbers (enter e to exit): 7346 Correct Location & Number : 0, Correct Number : 4 You have 7 remaining chance(s). Guess 4 numbers (enter e to exit): 3 4 67 Correct Location & Number : 1, Correct Number : 3 You have 6 remaining chance(s). Guess 4 numbers (enter e to exit): 6 47 3 Correct Location & Number : 4, Correct Number : 0 Excellent!!! you solved it with 5 guesses, in 96 seconds. Do you want to play another game? (No:0, Yes:1)1 **** You have 10 remaining chance(s). Guess 4 numbers (enter 0 to exit): 1 11 1 Correct Location & Number : 0, Correct Number : e You have 9 remaining chance(s). Guess 4 numbers (enter 0 to exit): 2 222 Correct Location & Number : 0, Correct Number : e You have 8 remaining chance(s). Guess 4 numbers (enter 0 to exit): 3 333 Correct Location & Number : 0, Correct Number : 0 You have 7 remaining chance(s). Guess 4 numbers (enter 0 to exit): 4 4 4 4 Correct Location & Number : 0, Correct Number : 0 You have 6 remaining chance(s). Guess 4 numbers (enter 0 to exit): 5555 Correct Location & Number : 1, Correct Number : e You have 5 remaining chance(s). Guess 4 numbers (enter 0 to exit): 6 6 6 6 Correct Location & Number : 1, Correct Number : e You have 4 remaining chance(s). Guess 4 numbers (enter 0 to exit): 7 777 Correct Location & Number : 1, Correct Number : e You have 3 remaining chance(s). Guess 4 numbers (enter 0 to exit): 8 8 88 Correct Location & Number : 1, Correct Number : e You have 2 remaining chance(s). Guess 4 numbers (enter 0 to exit): 5 67 8 Correct Location & Number : 2, Correct Number : 2 You have 1 remaining chance(s). Guess 4 numbers (enter 0 to exit): 5 6 87 Correct Location & Number : 1, Correct Number : 3 Sorry, You Lost :( Answer is:7 6 5 8 Do you want to play another game? (No:0, Yes:1)0 bash-3.2$

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

Is this really true, or am I just taking it for granted?

Answered: 1 week ago