Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need the answer as soon as possible. A correct answer will receive a like. Strict warning: AI responses are unacceptable. DK 1 6
I need the answer as soon as possible. A correct answer will receive a like. Strict warning: AI responses are unacceptable.
DK
c code
Please edit the code below with these additional steps:
Keep track of how many guesses the user made to guess the random target number and output one line to a file score.txt like last player took guesses to guess the correct number.""
Begin each game by reading the file score.txt to input a message of how many guesses the last player took to guess the correct number and output that information to the user, or if the file is empty, output a message that no player has played the game yet. Make sure you create the file score.txt first and have it empty the first time the game is played
libraries
#include
#include
#include
#include
#include
using namespace std;
Programmer defined data types
Special compiler dependent definitions
NONE
global constantsvariables
NONE
Programmer defined functions
void introductionstring obj, string ins; user introduction
bool isRepeatedGuessint uGuess,int guessesint nGuesses; repeated guesses
main program
int main
Data
string objective template for C programs and to test code""; program objective
string instructions This will be the user instructions...""; user instructions
srandtime;
int u rand; random number
const int guessLimit ; number of guesses user can guess
int nGuesses ; number of guesses
int guessesguessLimit; guess limit
int uGuess; user guesses
ofstream fout;
ifstream fin;
string s;
user introduction
introductionobjective instructions;
read line by line from secret.txt file and decode it by substituting each character
fin.openscoretxt;
if fin.good throw IO error"";
cout u endl;
cout Im thinking of a number between and Guess what it is : ;
whiletrue
if fin.good break;
cin uGuess;
if uGuess uGuess
cout Im only thinking of a number between and : ;
continue;
cin uGuess;
bool b isRepeatedGuessuGuessguesses,nGuesses;
ifb
cout You already guessed
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started