Create a new program, WordGuessingGame. Using a while loop, create a game for the user. The game requires the user to guess a secret word. The game does not end until the user guesses the word. After they win the game, they are prompted to choose to play again. The secret word that user must guess is "valentine". It is a case-sensitive analysis
With each guess...
Update your Word guessing game to check for how letters are correct regardless of length or position.
You have all the same requirements as before except with each guess the user it told if any of the letters are in the word and how many are in the correct position.
Sample output with secret word valentine:
Welcome to the word guessing game. Guess a word: borp The word is longer Correct letters: 0 Correct position: 0 Incorrect. Guess again: turtle The word is longer Correct letters: 4 Correct position: 0 Incorrect. Guess again: val The word is longer Correct letters: 3 Correct position: 3 //program continues from here...
Note that if a letter is in a guess multiple times you are allowed to count them as separate letters (e.g. both 't's in turtle are considered correct even though there's only 1 't' in "valentine")
**I did the first part. I need help with the CORRECT LETTERS and CORRECT POSITION#include<iostream>
#include <string>
int main()
{
char quit='y';
std::string word;
word = "valentine";
std::string guess;
while (quit=='y')
{
std::cout<<"Welcome to the word guessing game.\n";
std::cout<<"Guess a word: ";
std::cin>>guess;
if (guess!=word)
{
while (guess!=word)
{
if (guess.length()<word.length())
{
std::cout<<"The word is longer.\n";
std::cout<<"Incorrect. Guess again: ";
std::cin>>guess;
}
else if (guess.length()>word.length())
{
std::cout<<"The word is shorter.\n";
std::cout<<"Incorrect. Guess again: ";
std::cin>>guess;
}
else
{
int same=0;
int len=guess.length();
for (int i=0;i<len;i++)
{
if(guess[i] == word[i])
{
same++;
}
}
std::cout<<"You have "<<same<<" letters correct.\n";
std::cout<<"Incorrect. Guess again: ";
std::cin>>guess;
}
}
}
if (guess==word)
{
std::cout<<"You win!\n";
}
std::cout<<"Would you like to play again? (y/n)\n";
std::cin>>quit;
}
return(0);
}
/***********************game.cpp*********************************/
#include<iostream>
#include <string>
int main()
{
char quit='y';
std::string word;
word = "valentine";
std::string guess;
while (quit=='y')
{
std::cout<<"Welcome to the word guessing game.\n";
std::cout<<"Guess a word: ";
std::cin>>guess;
if (guess!=word)
{
while (guess!=word)
{
if (guess.length()<word.length())
{
std::cout<<"The word is
longer.\n";
int same=0,position=0;
int len=guess.length();
for (int i=0;i<len;i++)
{
for (int
j=0;j<len;j++)
{
if(guess[i] == word[j])
{
same++;
if(i==j){
position++;
}
}
}
}
std::cout<<"You have
"<<same<<" letters correct.\n";
std::cout<<"You have
"<<position<<" position correct.\n";
std::cout<<"Incorrect. Guess again: ";
std::cin>>guess;
}
else if (guess.length()>word.length())
{
std::cout<<"The word is shorter.\n";
int same=0,position=0;
int len=guess.length();
for (int i=0;i<len;i++)
{
for (int
j=0;j<len;j++)
{
if(guess[i] == word[j])
{
same++;
if(i==j){
position++;
}
}
}
}
std::cout<<"You have
"<<same<<" letters correct.\n";
std::cout<<"You have
"<<position<<" position correct.\n";
std::cout<<"Incorrect. Guess again: ";
std::cin>>guess;
}
else
{
int same=0,position=0;
int len=guess.length();
for (int i=0;i<word.length();i++)
{
for (int
j=0;j<len;j++)
{
if(guess[i] == word[j])
{
same++;
if(i==j){
position++;
}
}
}
}
std::cout<<"You have
"<<same<<" letters correct.\n";
std::cout<<"You have
"<<position<<" position correct.\n";
std::cout<<"Incorrect. Guess again: ";
std::cin>>guess;
}
}
}
if (guess==word)
{
std::cout<<"You win!\n";
}
std::cout<<"Would you like to play again? (y/n)\n";
std::cin>>quit;
}
return(0);
}
/***************************output***********************************8/
Welcome to the word guessing game.
Guess a word: borp
The word is longer.
You have 0 letters correct.
You have 0 position correct.
Incorrect. Guess again: turtle
The word is longer.
You have 4 letters correct.
You have 0 position correct.
Incorrect. Guess again: val
The word is longer.
You have 3 letters correct.
You have 3 position correct.
Incorrect. Guess again: valentine
You win!
Would you like to play again? (y/n)
n
--------------------------------

Thanks a lot, Please let me know if you have any problem..................
Create a new program, WordGuessingGame. Using a while loop, create a game for the user. The...
please c++ with functions *Modify the Guessing Game Write the secret number to a file. Then write each user guess and answer to the file. (on separate lines) Write the number of guesses to the file at the end of the game. After the game is finished, ask the user if they want to play again. If 'n' or 'N' don't play again, otherwise play again! NOTE: your file should have more than one game in it if the user...
I am trying to write this code which asks "Write a program that ask the user, the question: What is a^b? //The program generates two signed integers and gives the user four attempts to get the correct answer //a=- , b = + //a= + , b = - " So far this what I wrote. I am not sure how to do this correctly. #include<iostream> #include<cstdlib> #include<ctime> using namespace std; int main() { srand(time(0)); int guess,a,ans,b, k;...
In this project, you will write a complete program that allows the user to play a game of Mastermind against the computer. A Mastermind game has the following steps: 1. The codebreaker is prompted to enter two integers: the code length n, and the range of digits m. 2. The codemaker selects a code: a random sequence of n digits, each of which is in the range [0,m-1]. 3. The codebreaker is prompted to enter a guess, an n-digit sequence....
Need help with this C program? I cannot get it to compile. I have to use Microsoft Studio compiler for my course. It's a word game style program and I can't figure out where the issue is. \* Program *\ // Michael Paul Laessig, 07 / 17 / 2019. /*COP2220 Second Large Program (LargeProg2.c).*/ #define _CRT_SECURE_NO_DEPRECATE //Include the following libraries in the preprocessor directives: stdio.h, string.h, ctype.h #include <stdio.h> /*printf, scanf definitions*/ #include <string.h> /*stings definitions*/ #include <ctype.h> /*toupper, tolower...
Word Guessing Game Assignment Help Needed. This C++ (I'm using Visual Studio 2015) assignment is actually kind of confusing to me. I keep getting lost in all of the words even though these are supposed to instruct me as to how to do this. Can I please get some help as to where to start? Word guessing game: Overview: Create a game in which the user has a set number of tries to correctly guess a word. I highly recommend...
I would like to preface this by saying this is NOT a current homework assignment; but it is an assignment from 3 years ago before I dropped out of school. I am self teaching and am revisiting an old assignment. I am NOT asking for the entire program, I'm simply looking for help building the skeleton for the initial start of the game.MORE INFO: Player 1 will enter word(of any length / i have been using "Testing") for Player 2...
Write a Java application program that plays a number guessing game with the user. In the starter code that you are given to help you begin the project, you will find the following lines of code: Random generator = args.length == 0 ? new Random() : new Random(Integer.parseInt(args[0])); int secret = generator.nextInt(100); You must keep these lines of code in your program. If you delete these lines, or if you change thse lines in any way, then your program...
JAVA Develop a letter guessing game in this assignment using Java. Requirements: 1). When the game is started, generate a random letter between A and Z; 2). Display a message "I have a secret letter (A to Z), can you guess what it is?"; 3). Read the user's answer; 4). Compare the user's answer and the random secret letter generated; 5). If the user answer is before the random secret letter in the alphabet, display "Incorrect. Try something bigger" and...
Can someone help me make the output of this code more spaced out? #include<iostream> #include<cstdlib> using namespace std; int main() { int amount=1000,guess,answer,bet,count=0,win=0; float per; char ch; cout<<"Welcome to the high-low betting game.\nYou have $1000 to begin the game.\nValid guesses are numbers between 1 and 100.\n"; do { cout<<"Please enter a bet:\n"; cin>>bet; answer=rand()%100; for (int i=0;i<6;i++) { cout<<"Guess "<<i+1<<":"; ...
Create a script that presents a word-guessing game. Allow users to guess the word one letter at a time by entering a character in a form. Start by assigning a secret word to a variable. After each guess, print the word using asterisks for each remaining letter, but fill in the letters that the user guessed correctly. Store the user’s guess in a form field. For example, if the word you want users to guess is “suspicious” and the user...