CODE
/* ========================================================================== */
/* HEADER FILES */
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;
// Prototypes
void Printheading(int money);
void PrintPayout();
void GetBet(int money, int& bet);
int GetGuess(void);
int CalcNewMoney(int money, int bet, int guesses);
int PlayAgain(void);
int PlayGame(int money);
int Start_Balance = 1000;
char doagain;
char Play;
int noOfGuesses = 0;
int guess;
int check;
int random;
int GenerateRandomNumber();
double bank, winnings, total;
int money = 1000,
oldmoney = money;
/* ========================================================================== */
/* MAIN FUNCTION */
int main()
{
GenerateRandomNumber();
{
int random;
srand(static_cast<unsigned>(time(NULL)));
random = rand() % 100 + 1;
GetBet(int money, int& bet)
}
PrintPayout();
{
cout << "If you guess correctly within the first 6 guesses, you will" << endl;
cout << "win the amount of money you bet divided by the amount of guesses"
<< endl;
cout << "If you don't guess correctly within the first 6 guesses you" << endl;
cout << "lose the money that you bet" << endl;
}
GetGuess(int guess)
{
if (guess > random)
{
check = 1;
}
else if (guess < random)
{
check = -1;
}
else
{
check = 0;
}
return (GetGuess);
}
Playgame()
{
cout << "-----------------------------------------------" << endl;
cout << "Welcome to the High-Low betting game." << endl;
cout << "You have $" << Start_Balance << "to begin the game" << endl;
cout << "Valid guesses are between the numbers 1 and 100" <<endl;
cout << "-----------------------------------------------";
cout << "Would you like to play (y / n)" << endl;
Bank = 1000.00;
cin >> Play;
if (Play=='y')
{
winnings = GetBet/noOfGuesses
cout << "Great! Your payout will be as follows:" << endl << endl;
printPayout();
cout << "How money would you like to bet?" << endl;
GetBet(int money, int& bet);
while ((noOfGuesses < 7 ))
{
cout << "Now guess a number between 1 and 100" << endl;
cin >> guess;
noOfGuesses++;
GetGuess(guess);
if (GetGuess(guess) == 0)
{
total = CalcNewMoney;
cout << "Correct, you win " << winnings << ", your bank is now "
<< CalcNewMoney << endl
cout << "Do You Wanna Play Again?(Y/N)";
cin >> play;
break;
}
else if (GetGuess(guess) == -1)
{
cout << "Sorry too low try higher" << endl;
}
else if (GetGuess(guess) == 1)
{
cout << "Sorry too high try lower" << endl;
}
}
}
}
return 0;
}
/* HEADER FILES */
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;
// Prototypes
void Printheading(int money);
void PrintPayout();
void GetBet(int money, int& bet);
int GetGuess(void);
int CalcNewMoney(int money, int bet, int guesses);
int PlayAgain(void);
int PlayGame(int money);
int Start_Balance = 1000;
char doagain;
char Play;
int noOfGuesses = 0;
int guess;
int check;
int random;
int GenerateRandomNumber();
double bank, winnings, total;
int money = 1000,
oldmoney = money;
/* ========================================================================== */
/* MAIN FUNCTION */
int main()
{
GenerateRandomNumber();
{
int random;
srand(static_cast<unsigned>(time(NULL)));
random = rand() % 100 + 1;
GetBet(int money, int& bet)
}
PrintPayout();
{
cout << "If you guess correctly within the first 6 guesses, you will" << endl;
cout << "win the amount of money you bet divided by the amount of guesses"
<< endl;
cout << "If you don't guess correctly within the first 6 guesses you" << endl;
cout << "lose the money that you bet" << endl;
}
GetGuess(int guess)
{
if (guess > random)
{
check = 1;
}
else if (guess < random)
{
check = -1;
}
else
{
check = 0;
}
return (GetGuess);
}
Playgame()
{
cout << "-----------------------------------------------" << endl;
cout << "Welcome to the High-Low betting game." << endl;
cout << "You have $" << Start_Balance << "to begin the game" << endl;
cout << "Valid guesses are between the numbers 1 and 100" <<endl;
cout << "-----------------------------------------------";
cout << "Would you like to play (y / n)" << endl;
Bank = 1000.00;
cin >> Play;
if (Play=='y')
{
winnings = GetBet/noOfGuesses
cout << "Great! Your payout will be as follows:" << endl << endl;
printPayout();
cout << "How money would you like to bet?" << endl;
GetBet(int money, int& bet);
while ((noOfGuesses < 7 ))
{
cout << "Now guess a number between 1 and 100" << endl;
cin >> guess;
noOfGuesses++;
GetGuess(guess);
if (GetGuess(guess) == 0)
{
total = CalcNewMoney;
cout << "Correct, you win " << winnings << ", your bank is now "
<< CalcNewMoney << endl
cout << "Do You Wanna Play Again?(Y/N)";
cin >> play;
break;
}
else if (GetGuess(guess) == -1)
{
cout << "Sorry too low try higher" << endl;
}
else if (GetGuess(guess) == 1)
{
cout << "Sorry too high try lower" << endl;
}
}
}
}
return 0;
}
