Hey all, I am doing a Bowling Score program for my C++ class. Ive tried every peice of logic I know of, but cant get it to work still. Strikes and spares are whats giving me the problem. I can do everything else fine, its just those damn spikes and spares. Well, I am out of ideas and need help.
The program doesn't need to play bowling, it just asks you for your score, strikes, spares, and then makes the total pins knocked down, total strikes, and total spares, for the game. Any help would be appreciated!!
Here is what I have now, and I am out of ideas::
Code:
#include <iostream.h>
int main()
{
int Player1Total = 0;
int Player1Strikes = 0;
int Player1SpareFrame = 0;
int Player1StrikeFrame = 0;
int Player1StrikeFrame1 = 0;
char KeepGoing = 'f';
char Player1StrikeCheck;
char Player1SpareCheck;
// -----------------------------
int Player1A = 0; // frame 1
int Player1B = 0; // frame 2
int Player1C = 0; // frame 3
int Player1D = 0; // frame 4
int Player1E = 0; // frame 5
int Player1F = 0; // frame 6
int Player1G = 0; // frame 7
int Player1H = 0; // frame 8
int Player1I = 0; // frame 9
int Player1J = 0; // frame 10
// -----------------------------
cout << "Welcome to my Bowling Score Program.";
cout << "\nFirst, if you had any Spares, type 'y', if you had no spares, type 'n': ";
cin >> Player1SpareCheck;
if (Player1SpareCheck == 'y')
{
cout << "\nPlease enter which frame number you had a spare: ";
cin >> Player1SpareFrame;
}
if (Player1SpareCheck == 'n')
{
cout << "\nNo spares were had during the game..\n\n";
}
cout << "Second, if you had any Strikes, type 'y', if you had no strikes, type 'n': ";
cin >> Player1StrikeCheck;
if (Player1StrikeCheck == 'y')
{
cout << "\nHow many strikes did you have: ";
cin >> Player1Strikes;
if (Player1Strikes == 1)
{
cout << "\nWhich frame did you get the strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
}
if (Player1Strikes == 2)
{
while (KeepGoing != 'n')
{
cout << "\nWhich frame did you get a strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
cout << "To input another strike, type 'y'. After inputing your "<< Player1Strikes <<" strikes, type a 'n' here: ";
cin >> KeepGoing;
}
}
if (Player1Strikes == 3)
{
while (KeepGoing != 'n')
{
cout << "\nWhich frame did you get a strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
cout << "To input another strike, type 'y'. After inputing your "<< Player1Strikes <<" strikes, type a 'n' here: ";
cin >> KeepGoing;
}
}
if (Player1Strikes == 4)
{
while (KeepGoing != 'n')
{
cout << "\nWhich frame did you get a strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
cout << "To input another strike, type 'y'. After inputing your "<< Player1Strikes <<" strikes, type a 'n' here: ";
cin >> KeepGoing;
}
}
if (Player1Strikes == 5)
{
while (KeepGoing != 'n')
{
cout << "\nWhich frame did you get a strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
cout << "To input another strike, type 'y'. After inputing your "<< Player1Strikes <<" strikes, type a 'n' here: ";
cin >> KeepGoing;
}
}
if (Player1Strikes == 6)
{
while (KeepGoing != 'n')
{
cout << "\nWhich frame did you get a strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
cout << "To input another strike, type 'y'. After inputing your "<< Player1Strikes <<" strikes, type a 'n' here: ";
cin >> KeepGoing;
}
}
if (Player1Strikes == 7)
{
while (KeepGoing != 'n')
{
cout << "\nWhich frame did you get a strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
cout << "To input another strike, type 'y'. After inputing your "<< Player1Strikes <<" strikes, type a 'n' here: ";
cin >> KeepGoing;
}
}
if (Player1Strikes == 8)
{
while (KeepGoing != 'n')
{
cout << "\nWhich frame did you get a strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
cout << "To input another strike, type 'y'. After inputing your "<< Player1Strikes <<" strikes, type a 'n' here: ";
cin >> KeepGoing;
}
}
if (Player1Strikes == 9)
{
while (KeepGoing != 'n')
{
cout << "\nWhich frame did you get a strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
cout << "To input another strike, type 'y'. After inputing your "<< Player1Strikes <<" strikes, type a 'n' here: ";
cin >> KeepGoing;
}
}
if (Player1Strikes == 10)
{
while (KeepGoing != 'n')
{
cout << "\nWhich frame did you get a strike: ";
cin >> Player1StrikeFrame1;
if (Player1StrikeFrame1 == 1)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1A;
}
if (Player1StrikeFrame1 == 2)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1B;
}
if (Player1StrikeFrame1 == 3)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1C;
}
if (Player1StrikeFrame1 == 4)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1D;
}
if (Player1StrikeFrame1 == 5)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1E;
}
if (Player1StrikeFrame1 == 6)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1F;
}
if (Player1StrikeFrame1 == 7)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1G;
}
if (Player1StrikeFrame1 == 8)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1H;
}
if (Player1StrikeFrame1 == 9)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1I;
}
if (Player1StrikeFrame1 == 10)
{
cout << "\nWhat was the total amount of pins dropped during that frame: ";
cin >> Player1J;
}
cout << "To input another strike, type 'y'. After inputing your "<< Player1Strikes <<" strikes, type a 'n' here: ";
cin >> KeepGoing;
}
}
}
if (Player1StrikeCheck == 'n')
{
cout << "\nNo strikes were had during the game..\n\n";
}
if (Player1A == 0)
{
cout << "\nNow please enter your score for Frame 1: ";
cin >> Player1A;
}
if (Player1B == 0)
{
cout << "\nNow please enter your score for Frame 2: ";
cin >> Player1B;
}
if (Player1C == 0)
{
cout << "\nNow please enter your score for Frame 3: ";
cin >> Player1C;
}
if (Player1D == 0)
{
cout << "\nNow please enter your score for Frame 4: ";
cin >> Player1D;
}
if (Player1E == 0)
{
cout << "\nNow please enter your score for Frame 5: ";
cin >> Player1E;
}
if (Player1F == 0)
{
cout << "\nNow please enter your score for Frame 6: ";
cin >> Player1F;
}
if (Player1G == 0)
{
cout << "\nNow please enter your score for Frame 7: ";
cin >> Player1G;
}
if (Player1H == 0)
{
cout << "\nNow please enter your score for Frame 8: ";
cin >> Player1H;
}
if (Player1I == 0)
{
cout << "\nNow please enter your score for Frame 9: ";
cin >> Player1I;
}
if (Player1J == 0)
{
cout << "\nNow please enter your score for Frame 10: ";
cin >> Player1J;
}
cout << "\nPlayer 1's Scores: ";
cout << "|" << Player1A;
cout << "|" << Player1B;
cout << "|" << Player1C;
cout << "|" << Player1D;
cout << "|" << Player1E;
cout << "|" << Player1F;
cout << "|" << Player1G;
cout << "|" << Player1H;
cout << "|" << Player1I;
cout << "|" << Player1J;
cout << "|" << endl;
// Player1StrikesFunction();
// Player1StrikesTemp = Player1Strikes;
// Player1Strikes = Player1StrikesTemp;
Player1Total = Player1A + Player1A + Player1B + Player1C + Player1D + Player1E + Player1F + Player1G + Player1H + Player1I + Player1J;
cout << "\n\nTotal Pins Knocked Down: " << Player1Total;
cout << "\nTotal Strikes: " << Player1Strikes;
cout << "\nSpare (if any) Frame: " << Player1SpareFrame;
cout << "\n\n";
return 0;
}
Thanks!
P.S. - We use Visual C++ 2003, so I don't use "using namespace std" and the like.