I have been working on this program for school, it does some things right but with a few things I am struggling.
For this assignment you will be writing a two person chip game. You will start out with a pile of 1000 chips. Each player will have the chance to pick up (at most) half of the pile of chips. This will continue until one of the players gets the last chip. Whomever gets the last chip is the winner.
I cannot get the code down to 0 and I also cannot figure out how to declare a winner. I would really appreciate any help!!
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int chips,
chips1,
chips2,
threshold = 1000;
string player_1,
player_2;
cout << "You will start out with a pile of 1000 chips.";
cout << "\nEach player will have the chance to pick up (at most) half of the pile of chips.";
cout << "\nThis will continue until one of the players gets the last chip.";
cout << "\nWhomever gets the last chip is the winner.";
cout << "\n\nPlayer 1 please enter your name: ";
cin >> player_1;
cout << "\nPlayer 2 please enter your name: ";
cin >> player_2;
while (chips >= 0)
{ cout << "\n"<<player_1<<" please enter a quantity of chips ("<<((threshold += 1)/2)<<" max) ";
cin >> chips1;
while (chips1 <=0)
{
if (chips1 <= 0)
cout << "\nYou cannot enter zero or negative chips! Please try a different amount: ";
cin >> chips1;
if (chips1 >= ((threshold += 1) / 2))
cout << "\nThe amount requested is too high!Please re enter: ";
cin >> chips1;
if (chips1= 0)
cout << "\n"<<player_1<<"Wins!";
}
threshold = threshold -= chips1;
cout << "\n"<<player_2<<" please enter a quantity of chips ("<<((threshold += 1)/2)<<" max) ";
cin >> chips2;
while (chips2 <=0)
{
if (chips2 <= 0)
cout << "\nYou cannot enter zero or negative chips! Please try a different amount: ";
cin >> chips2;
if (chips2 >= ((threshold += 1) / 2))
cout << "\nThe amount requested is too high! Please re enter: ";
cin >> chips2;
if (chips2= 0)
cout << "\n"<<player_1<<"Wins!";
}
threshold = threshold -= chips2;
}
return 0;
}