quiz حل الأسئلة الجامعية manage_search الأرشيف

تم الحل ✓
categoryبرمجة وتطوير البرمجيات schoolبكالوريوس event_available2026-07-14

السؤال

Transcribed Image Text:

Spinning the Wheel If the user has typed spin, it means the user wishes to "Spin the Wheel" and guess a letter in the puzzle. A function called spinTheWheel should be called. spinTheWheel should perform the following actions: O Randomly Select a Wheel Value: A "spin of the wheel" should randomly select one of the following 24 values: $50, $100, $100, $100, $100, $100, $100, $200, $200, $200, $200, $250, $250, $250, $500, $500, $750, $750, $1000, $2000, $5000, $10000, Bankrupt, Bankrupt. The amount the player has spun should be output to the screen. IMPORTANT: If a player spins a "Bankrupt", their current winnings should be erased and re-set to $0. The user should not be allowed to guess a consonant; their turn is over. ○ Ask the user to guess a consonant: If the player has not "spun" a Bankrupt, they should be asked to guess a consonant (consonants are all letters in the English alphabet except for A, E, I, O, U). If the user correctly guesses a consonant in the phrase, they should have the following added to their current winnings: (the number of occurrences of that consonant)*(value of the wheel spin). If, however, the user guesses incorrectly (the consonant does not appear in the phrase) the dollar amount of the spin should be deducted from their winnings. The player should be informed if the letter they guessed is in the phrase, and if so, how many times. The should also be informed how much they have won (or lost) on the turn. O Return the user's winnings, the consonant guessed, and if the guess was correct: The function should return the user's updated total winnings, the consonant the player guessed, and if their guess was in the phrase. O HINT: spin The Wheel should have two input arguments: the puzzle solution (this is the random phrase drawn at the start of the game) and the player's current balance before the turn is taken After the player has completed a spin turn, the phrase should be printed with all correctly guessed letters in place of blanks, the category should be re-printed, the vowels guessed so far should be printed, the consonants guessed so far should be printed, the current winnings should be printed, and the player should be asked what they would like to do next. Buying a Vowel If a user types vowel, the player has opted to "buy a vowel." Since A, E, I, O, and U are common letters in English words, in order to guess one of these letters the user must pay $250. The price to buy a vowel is always $250, regardless of how many times the vowel appears in the phrase (even if the vowel does not appear at all!). Note that if a user chooses to buy a vowel, they must have accumulated at least $250. Since users start the game with $0, this means a user cannot buy a vowel on their first turn. When the user types vowel, a function named buyAVowel should be called. buyAVowel should perform the following actions: O Check the player's winnings: A user must have at least $250 in their winnings to buy a vowel. If the user does not have at least $250, they should not be allowed to proceed with buying a vowel. ○ Ask the user which vowel they would like to buy: The user should be informed that $250 will be deducted from their winnings, and asked which vowel they would like to buy. If the vowel selected by the player appears in the phrase, the player should be informed how many times the letter appears. If it does not appear, they should be informed of this as well. O Update the user's winnings: Regardless of whether the vowel appears in the phrase, $250 should be deducted from the user's winnings. O Return the user's winnings, the vowel guessed, and if the guess was correct: The function should return the user's updated winnings, the vowel the player guessed, and if their guess was in the phrase. O HINT: buyAVowel needs two input arguments: the puzzle solution (this is the random phrase drawn at the start of the game) and the player's current balance before the turn is taken After the player has completed buying a vowel, the phrase should be printed with all correctly guessed letters in place of blanks, the category should be re-printed, the vowels guessed so far should be printed, the consonants guessed so far should be printed, the current winnings should be printed, and the player should be asked what they would like to do next. Solving the Puzzle If the user types solve, this means they would like try and guess the puzzle phrase. A function named solveThePuzzle should be called. solve The Puzzle should perform the following actions: ○ Ask the user what their guess is: The user should be prompted to enter a guess for the phrase. The user should be asked to enter their response with single spaces. O Check to see if the guess matches the phrase: The player's guess should be checked against the original phrase. If the guess is correct, the user has won a message should be output to the user indicating they have correctly solved the puzzle. If the user has not correctly guessed the puzzle, they should be informed their guess was incorrect and their winnings should be re-set to $0. O Return the user's winnings and if the guess was correct: The function should return the user's winnings and if they correctly guessed the phrase. At this point, the user has either correctly guessed the puzzle and reached the End of Game (see below), or incorrectly guessed the puzzle. If they have incorrectly guessed the puzzle, the phrase should be printed with all correctly guessed letters in place of blanks, the category should be re-printed, the current winnings should be printed, and the player should be asked what they would like to do next.

check_circle الجواب — حل مفصل خطوة بخطوة

hourglass_top