Modify C++ code. 1-if numberof

Modify C++ code.
1-if numberoftries used by user but not guess the correct answer print You can;t guess the correct random number and then print on second line” The correct random number is ——- “this.
2-Then ask from user if you want to play again or not if not then excute the program.
 
Code:
 
//included header file for basic input output stream
#include <iostream>
  //included header file for file stream
#include <fstream>
  //included header file to use rand() function
#include <cstdlib>
  //included header file to use time() function
#include <ctime>
  //included namespace
using namespace std;
//function to generate random number
int generateRandom();
void tooLow();
void tooHigh();
void guessedCorrect();
void checkGuess(int guess, int randomNumber);
void guessGame();

 

int generateRandom()
{
  //use srand() function to change the random number after each execution
  srand((unsigned int) time(0));
  //generated a random number between 1-50 through rand() function
  int randomNumber = ((rand() % 50)+1);
  //return random number to main()
  return randomNumber;
}

 

//function tooLow()
void tooLow()
{
  //print statement to print the message
  cout << “You have guessed too low.” << endl;
}

 

//function tooHigh()
void tooHigh()
{
  //print statement to print the message
  cout << “You have guessed too high.” << endl;
}

 

//function guessedCorrect()
void guessedCorrect()
{
  char choice;
  //print statement to print the message
  cout << “You have guessed correct.” << endl;
  cout << “\nDo you want to play again (Y or N): ” << endl;
  cin >> choice;
  switch (choice)
  {
    case ‘y’:
      guessGame();
      break;
    case ‘n’:
      exit(0);
  }

 

  cout << endl;
}

 

//function to check guess
void checkGuess(int guess, int randomNumber)
{
  //If the users guesses below the number
  if (guess < randomNumber)
    //call a function tooLow()
    tooLow();
  //If they guess over that number
  else if(guess > randomNumber)
  //call a function tooHigh()
  tooHigh();
  //else statement
  else
    //call a function guessedCorrect()
    guessedCorrect();
}

 

//function to start game
void guessGame()
{
  //welcome message
  cout << “————Welcome to the game————” << endl;
  //variable declaration
  int guess, level, trial = 0, numberOfTries;
  cout << “Enter level of game: ” << endl;
  cout << “Press 1 for easy level” << endl;
  cout << “Press 2 for medium level” << endl;
  cout << “Press 3 for hard level” << endl;
  //input level
  cin >> level;
  //switch level
  switch (level)
  {
    //case 1
    case 1:
      //assign numberOfTries to 8
      numberOfTries = 8;
    //break
    break;
    //case 2
    case 2:
      //assign numberOfTries to 5
      numberOfTries = 5;
    //break
    break;
    //case 3
    case 3:
      //assign numberOfTries to 2
      numberOfTries = 2;
    //break
    break;
    //default case
    default:
      //display message “Wrong choice entered.”
      cout << “Wrong choice entered.” << endl;
  }

 

  //while loop run until numberOfTries
  //calling generateRandom
  int randomNumber = generateRandom();
  while (trial < numberOfTries)
  {
    cout << “Enter your guess: “;
    //input number from user
    cin >> guess;

 

    //calling checkGuess()
    checkGuess(guess, randomNumber);
    //increment trial
    trial++;
  }
}

 

//main function
int main()
{
int randomNumber;
  //declared variable guess
  int pin, filePin;
  int i = 0;
  //created file
  ifstream file;
  //opening file
  file.open(“gamePin.txt”);
  //input pin from user
  while (i < 3)
  {
    cout << “Enter pin: “;
    cin >> pin;
    //extract pin from file
    file >> filePin;
    //compare user pin and pin in file
    if (pin == filePin)
    {
      //calling guessGame()
      guessGame();
      break;
    }

 

    //else statement
    else
    {
      //display message “Wrong pin”
      cout << “Wrong pin” << endl;
      i++;
    }
  }

 

  return 0;
}

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more