You will implement the program for playing a modified Wheel of Fortune. The game
ID: 3667356 • Letter: Y
Question
You will implement the program for playing a modified Wheel of Fortune. The game must allow a user to enter the number of rounds to play and a new secret message (possibly containing blanks) with each round, and print the number of dashes/slots for the message (spaces do not get dashes, just the space) The game can play with 1-3 players, and it continues a round, until someone solves the puzzle correctly. A new puzzle is given with each round. In this Wheel of Fortune, you won't win as much or any prizes, but you might go bankrupt or lose a turn!!! Your random numbers are only from 0-21, with 0 being bankrupt, 1-20 being the dollar amount earned per letter found in the puzzle, and 21 is lose a turn. The game begins by asking the first player if he/she wants to spin the wheel, buy a vowel, or solve the puzzle. On a player's first turn, it might not make sense to choose anything other than spinning the wheel, but a player is given these three choices at all times during their turn, until they guess an incorrect non-vowel letter, incorrectly solve the puzzle, or spin a 0 or 21 If the player chooses to spin and the spin is >0 and = $10, which is the one-time amount paid for each vowel guess, regardless of whether the vowel is found The player who has the most money after N rounds is the winner!Explanation / Answer
#include<iostream.h>
#include<string.h>
#include<time.h>
#include<iomanip.h>
using namespace std;
void initial (string& phrase, string& puzzle)
{
int i;
string input;
cout << "Please enter your secret message";
cin >> input;
cout << "Here is your phrase: " << endl;
getline(input, phrase);
for(i = 0;i< phrase.length();i++)
{
puzzle.insert (i,”-“);
}
cout << puzzle;
} //end of function initial
int wheel_spin()
{
int spin;
int Max=21;
int rotation[22];
spin = rand() % 21;
cout << rotation[spin] << endl << endl;
return(spin);
}
bool play(int rounds,int totalearned, string phrase, string& puzzle)
{
char choice, letter;
bool validChoice = false;
for(int i=0;i<rounds;i++)
{
cout << "Do you want to spin(1), solve the puzzle(2),buy a vowel(3)" << endl;
cin >> choice;
while (!validChoice)
{
validChoice = false;
switch (choice)
{
case '1': int spinNum= wheel_spin();
cout << “your wheel landed on:”<<spinNum<<endl;
cout << "Guess a letter ->";
cin >> letter;
int counter= isFound(letter);
cout <<”found”<<counter<<”times”<<endl;
int totalearned= spinNum*counter;
cout<<”$”<<totalearned<<endl;
validChoice = true;
break;
case '2':string message;
cout << “guess a message”<<endl;
cin>>meassage;
bool puzzle_solve (&phrase,message,round);
validChoice = true;
break;
case '3': char guess;
cout <<”guess a vowel ”<<endl;
cin>>guess;
bool buy_a_vowel(phrase,&puzzle,guess, totalearned);
validChoice = true;
break;
default : cout << "Please enter valid number" << endl;
}
}
}
return(play);
}
void puzzle_solve(string phrase,string message, int round)
{
for(int i=0;i<phrase.length();i++);
{
if(message.charAt(i)== phrase.charAt(i))
{
cout<<”You are correct! You win the round”<<round<<endl;
}
}
} // end of puzzle_solve method
int isFound (char letter, string& phrase)
{
int i;
int counter=0;
for(i=0;i<phrase.length();i++)
{
if(phrase.charAt(i) == letter)
{
counter++;
}
}
return(counter);
}
void buy_vowel(string phrase,string &puzzle, char guess,int totalearned)
{
Int counter=0;
for(int i=0;i<phrase.length();i++)
{
if(guess==”a” ||guess==”e” ||guess=”i” || guess==”o” ||guess==”u”)
{
if(guess== phrase.charAt(i))
{
puzzle.charAt(i)== phrase.charAt(i);
cout<<puzzle<<endl;
counter++;
}
}
}
totalearned= totalearned-(counter*10) ;
cout<<”$”<<totalearned;
}
int main()
{
string puzzle, phrase;
int totalearned;
int playes,rounds;
initial(phrase,puzzle);
cout<<”how many players do you have”;
cin>>players;
cout<<”how many rounds for winning”;
cin>>rounds;
for(int i=0;i<players;i++)
{
play(rounds,totalearned,phrase,puzzle);
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.