Write a text file with the original number in it and then


By completing this project, you will demonstrate your understanding of:

1) Arithmetic operations (addition, subtraction, multiplication, division, modulus)

2) Conditional statements (If, If-Else, If-ElseIf-Else, Conditional Operator, Switch)

3) Precondition, postcondition, and indexing loops (Do-While, While, For)

4) Standard text file operations (open, close, read, write)

5) Modularizing code by breaking into functions (including functions with input parameters, and ones that return a specific data type)

There is a number guessing game similar to MasterMind called Pico-Fermi-Bagel. In this game, the leader chooses a 3-digit number that must not contain individual digits that are the same, and must be a 3-digit number. (In other words, 999 is not ok (3 digits, but the digits repeat), 25 is not ok (2 digits - cannot lead off with a zero), 121 is not ok either (3 digits, but 2 of the digits are the same).) The leader does not reveal the number to the players. The players must guess the number. If the players guess no digits in the number, that is called a "Bagel" - because bagels look like zeros. If a guess contains one or more digits that are in the number, but not in the right placevalue, then each of those is a "Pico" - pico means little, and the answer is a "little right". If the guess contains one or more digits that are in the number AND in the right placevalue, then each of those is a "Fermi" - Fermi was a famous scientist; look it up.

Example. The leader picks 451

Player guess 1: 120 - this is a Pico because the 1 is in the actual number, but in the wrong place value.

Player guess 2: 879 - this is a Bagel because none of the digits are in the number (we like bagels, they tell us a lot!)

Player guess 3: 615 - This is a PicoPico (the 1 and the 5 are in the final number, but in the wrong places).

Player guess 4: 541 - this is a PicoPicoFermi (the 1 is in the correct place, the 4 and 5 are in the number but in the wrong places. Now we know the answer on the next guess.

The project: Create a version of PicoFermiBagel.

- Your code must include a function that picks the 3-digit number, and a function that checks the user input.

- You must write a text file with the original number in it, and then all the user should enter a number to guess and the computer responses between pico, fermi, bagel from each of guesses. You must ask the user for the name of the file to save. So, given the example above, the text file would look something like this:

451

120: Pico

879: Bagel

615: Pico Pico

541: Pico Pico Fermi

451: Fermi Fermi Fermi

- Your code must have a function that checks for valid input (a positive 3-digit number input), and asks the user again for input if the number is not valid.

- Your code needs to have a way for the user to "quit" the game.

- Your code needs to have a way for the user to play again without restarting the program. In this case, the new game information should be added at the end of the file you have created.

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Write a text file with the original number in it and then
Reference No:- TGS02372515

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)