mercredi 4 décembre 2019

Hi, I'm having a problem solving my program can you please help me solve it? [closed]

  1. You will develop a C++ game of your choice! You can choose the game of your choice. Below is a list of possible games. CHOOSE ONE from the list provided. Don’t forget to read the requirements (steps 5,6,7 below): • (Easy) Hi-Lo Guessing game: o Have the computer generate a random number between 1 and 100 (code to generate random numbers is included in step 4 below).
    o Use a for loop to allow users to have 10 chances to guess the number (you can use a while loop if desired to give user unlimited tries, ex: while user has not guessed the number).
    ▪ Prompt user for a number between 1 and 100.
    ▪ Read in the number using cin. ▪ If the number is less than the secret number, print a message stating it’s too low. ▪ Else if the number is higher than the secret number, print a message stating it’s too high. ▪ Else if the number is == to the secret number, then print an appropriate message and exit • (Easy) Mad Libs:
    o Create a story with blanks. For example: Last month, I went to ________ (city) with __________ (name of person). We traveled for __________(number) hours by __________(vehicle).
    o The following website contains samples, but you can come up with your own or modify one you find on-line: http://www.teach-nology.com/worksheets/language_arts/madlibs/ o Make sure the story is appropriate for all ages!
    o The story must be longer than one sentence 😊. I only included a sentence above as an example, but your story should be at least a few sentences.
    o Prompt the user for the necessary words. For example, for our short example listed above, I would prompt the user for a name of a person (read it in as a string). Then I would prompt them for a number (read it in as a double) and then prompt them for a vehicle (read it in as a string).
    o Then print out the story with the words that the user entered: Last month, I went to Paris with Oprah. We traveled for 1000 hours by bicycle. o The story will vary depending on what the user entered. There are many examples of this online (http://www.redkid.net/madlibs/).
    o (Optional) To make the program more robust, have more than one story available, and use random

    number to pick the story or have user pick the story. Make it as simple or complex as you like!

• (Easy) Magic 8-ball:
o Prompt the user to enter a yes or no question (Will it rain? Will I make an A? etc…). o Read in the question using getline(). o Generate a random number between 0-7.
o Create an array of strings with 8 items. The 8 strings will all be yes/no type phrases (“Absolutely!!!”, “There is no way that will ever happen!”, etc…).
o Based on the random number, print out the position in the array.
o If you’re not sure what a magic 8-ball is, you can pick another project 😊 • (Easy) Funny Face:
o Prompt the user for one character to represent a nose. Read in the character. o Prompt the user for one character to represent an eye. Read in the character. o Prompt the user for one character to represent a mouth. Read in the character. o Based on the characters entered, print out a funny face. o (Optional, but recommended) To make the program more robust, use a random number to choose between a few different funny faces so they aren’t always the same. Here is an example:

Enter a nose: < Enter an eye: x Enter a mouth: -

||||| / \ x x @ < @


• (Easy to Moderate) Palindrome:
o Prompt the user for a word or phrase. o Read in the word or phrase (it’s up to you if you want to deal with phrases). o Check to see if it’s a palindrome. If you use a phrase, ignore spaces and punctuation. o Print out an appropriate response. • (Moderate) Rock/Paper/Scissors: Have user enter a rock (r), paper (p) or scissor (s) or you can have them choose from a menu. Have computer randomly generate its own guess (random number between 0-2 and then assign a value based on random number). Print out the computer’s guess and user’s choice and tell the user who won. Remember, Rock beats Scissors, Rock loses to Paper, Paper beats Rock, Paper loses to Scissors, Scissors beats Paper, Scissor loses to Rock. (Optional: A more advanced version is using the version of the game from the Big Bang Theory 😊). • (Moderate) Tic/Tac/Toe: Have TWO users play against each other, which is easier than playing against the computer. You will want to use a 2-dimensional array to create a board.
• (Harder) Hangman
• (Harder) Memory
• (Harder) Battleship

  1. If your game needs to generate a random number: I like to use FIVE steps when trying to generate a random number. You will need two preprocessor directives at the top of your program, you will then need to declare/define a variable to hold the random number, then you will need two lines to actually create the number. For example, to generate a random number between 0 and 9 (aka. 10 possible numbers), you will need the following code:

    include //STEP 1 out of 5 for random numbers

include //STEP 2 of 5 for random numbers

int num; //STEP 3 of 5 create var to store the random number srand(time(0)); //STEP 4 of 5 for random numbers num = rand() % 10; //STEP 5 of 5 for random numbers If you want to generate a random number between 0 and 99 (aka. 100 numbers), change STEP 5 to: num = rand() % 100; //STEP 5 of 5 for random numbers If you want to generate a random number between 1 and 100 (aka. 100 numbers), change STEP 5 to: num = rand() % 100 + 1; //STEP 5 of 5 for random numbers If you want to generate a random number between 0 and 7 (aka. 8 numbers), change STEP 5 to: num = rand() % 8; //STEP 5 of 5 for random numbers

  1. You must include comments!

  2. It is imperative that your output looks professional! That is, no typos! Use capital letters at the beginning of a sentence or phrase. Use punctuation when appropriate. Make the output neat. ETC…

  3. You must make your program modular. That is, you must use functions!!! For example, if you chose to create the HiLo Guessing game, have a function to read in the number, have a function to create the random number perhaps, etc… Write your program using at LEAST 1 function, though 2 or more functions will be required for making the highest possible grade.

  4. (OPTIONAL) If you would like to write more than one game, create a menu of games for the user to choose. For example:

    1436 Games Menu

  5. Hi/Lo Game

  6. Magic 8 ball
  7. Tic Tac Toe
  8. Quit You may write your own game as long as you have completed at least ONE from the list given above in step 3. If you would like to create a game that is not on the list, use this option to create a menu and add your game on the list. Again, make sure one of the games on the list is from the list of games we provided.



Aucun commentaire:

Enregistrer un commentaire