I once again am having trouble with this program. I really thought i understood this right off the bat but once i got into it, there is a lot of little technical things my professor wants in it. Like the functions and generating random numbers. Any help would be awesom, i just got done with my other assignment now i have this one due friday....i have an attached file of what the output should look like...
//Assignment 5: Guessing game with random numbers and functions
//By Curtis Davenport 2/17/08
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <math>
using namespace std;
int GuessFunction (int)
int main()
{
int guess;
int target;
int chancesLeft;
bool foundTarget = false;
bool endGame = false;
chancesLeft=5 //I need to give a random target for the user to hit and do
//a guess function for it.
target =???? //I dont know how to set up for a user to input a number so he/she
//can hit a random target.
do //Overall I need to give the user 5 guesses and give options after.
{
cout << "Guess a number (0-100): ";
cin >> guess;
if (guess < target)
{
cout << "Your Guess is too LOW!!! \n";
}
if (guess > target)
{
cout << "Your Guess is too HIGH!!! \n";
}
if (
chancesLeft--;
if (guess == target)
{
foundTarget = true;
endGame = true;
}
if (chancesLeft == 0)
{
endGame = true;
}
} while (!endGame);
if (foundTarget)
{
cout << "You got it right!!! \n";
}
else
{
cout << "You ran out of chances. \n";
return 0;
}
int GuessFunction(int)
{ // I am supposed to use a function here, do not know how to set it up.
int result;
srand( time(0) );
result =
return result;
}
//I am supposed to
// (1)Write a program that generates a random integer number
// between 1 and 100 and allows the user to make a maximum of
// five 5 attempts to guess the number.
// (2)The program must let the user know whether the current guess is too high or too low.
// (3)The program must notify the user if he/she made the right guess or ran out of chances.
// (4)At the end of the cycle the program must ask the user for a choice of
// trying again 1 or exiting 2. This answer must be validated (only 1 or 2 are acceptable).
// (5)Seed the random number generation sequence at the beginning of the program using
// the current time in seconds.
// (6)The random target value must be generated inside the main function and passed
// as an input parameter to a Guess function.
// (7)The Guess function must ask the user to enter the guess value, compare it
// with the target, notify the user if the guess is too high or too low, accumulate
// the number of attempts, and check if the maximum number of attempts has been reached.
// (8)The Guess function must return the number of attempts by the user to the main
// function and the main function must use this value to notify the user whether he/she
// ran out of chances or made the right guess.