Need Help with a Bowling Score Program

This is a discussion on Need Help with a Bowling Score Program within the C++ Programming forums, part of the General Programming Boards category; Hey all, I am doing a Bowling Score program for my C++ class. Ive tried every peice of logic I ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    97

    Need Help with a Bowling Score Program

    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.

  2. #2
    Bioport Productions
    Join Date
    Oct 2005
    Posts
    215
    Advice: Clearly display your problem in english, I dunno about the others but I don't want to go through 100000 lines of code looking for something that I have no clue in what mile of the page it is on. Is this an algorithm problem? compile errors? if so, what are they?
    -"What we wish, we readily believe, and what we ourselves think, we imagine others think also."
    PHP Code:
    sadf 

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    38
    Personally i tihnk that code is very messy:

    Ive made a simple one (only does one frame) however it is very easy to change for 10frames. Also you dont seem to see that if they get a strike or half then 10pins must have been knocked down.

    Code:
    #include <iostream>
    
    using namespace std;
    
    struct bowling {
          int frame1;
          int frame2;
          int frame3;
          int frame4;
          int frame5;
          int frame6;
          int frame7;
          int frame8;
          int frame9;
          int frame10;
          int strikes;
          int halfs;
    } person;
    
    int strike(int frame) {
        char yn[2];
        cout<<"Did you get a strike in Frame "<<frame<<"? (y or n): ";
        cin>>yn;
        if (!strcmp(yn, "y")) {
                        return 1;
        }
        else {
             return 0;
        }
    }               
    
    int halfst(int frame) {
        char yn[2];
        cout<<"Did you get a half strike in Frame "<<frame<<"? (y or n): ";
        cin>>yn;
        if (!strcmp(yn, "y")) {
                        return 1;
        }
        else {
             return 0;
        }
    }  
    
    int main() {
        int strike1 = 0;
        int half = 0;
        int pins;
        cout << "Bowling Score Sheet" << endl;
        cout<<"FRAME 1:" << endl << endl;
        strike1 = strike(1);
        if (strike1 == 1) {
                    person.frame1 = 10;
                    person.strikes++;
        }
        else if (strike1 == 0) {
             half = halfst(1);
             if (half == 1) {
                        person.frame1 = 10;
                        person.halfs++;
             }
             else if (halfst == 0) {
                  cout << "How many pins were knocked down in frame 1?: ";
                  cin>>pins;
                  person.frame1 = pins;
             }
        }
        cout<<endl<<endl<<person.frame1<<" "<<person.strikes<<" "<<person.halfs;                
        cin>>pins;     
        return 0;
    }

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    38
    Opps:

    Code:
    else if (halfst == 0) {
                  cout << "How many pins were knocked down in frame 1?: ";
                  cin>>pins;
                  person.frame1 = pins;
    should be

    Code:
    else if (half == 0) {
                  cout << "How many pins were knocked down in frame 1?: ";
                  cin>>pins;
                  person.frame1 = pins;

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,338
    >> We use Visual C++ 2003, so I don't use "using namespace std" and the like.

    Visual C++ 2003 doesn't accept iostream.h, maybe you mean version 6.0? Also, just because you have an old compiler that works with old code doesn't mean it's a good idea use the old code that doesn't work on newer compilers. Many people here don't have old compilers and don't want to be bothered to fix your code to be standards compliant so that they can compile and run it and help you. Or, if you give a specific problem like durban mentioned, then we might not have to compile it to figure out the problem.

    At first glance, your algorithm is all wrong. TO score bowling, you need to know each pin count in order from start to finish. If the first ball is 10, then it is a strike, otherwise if the first and second ball add up to ten, it is a spare. Try coming up with a better algorithm on paper before trying to implement it.

    >> Opps: should be
    You can edit your post and make the change.

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    97
    heres what i got so far:

    Code:
    #include <iostream>
    using namespace std;
    
    struct bowling
    {
          int frame1;
          int frame2;
          int frame3;
          int frame4;
          int frame5;
          int frame6;
          int frame7;
          int frame8;
          int frame9;
          int frame10;
          int strikes;
          int halfs;
    } person;
    
    // Function, "strike" ~~~~~~~~~~
    int strike(int frame)
    {
        char yn[2];
        
        cout << "Did you get a strike in Frame " << frame << "? (y or n):  ";
        cin >> yn;
        if (!strcmp(yn, "y"))
        {
            return 1;
        }
            else 
            {
                return 0;
            }
    }
          
    // Function, "halfst" ~~~~~~~~~~
    int halfst(int frame) 
    {
        char yn[2];
        
        cout << "Did you get a half strike in Frame " << frame << "? (y or n):  ";
        cin >> yn;
        if (!strcmp(yn, "y"))
        {
            return 1;
        }
            else 
            {
                    return 0;
            }
    }
    
    int main()
    {
        int strike1 = 0;
        int half = 0;
        int pins;
        
        cout << "Bowling Score Sheet" << endl;
        cout << "\nFRAME 1:  " << endl;
        strike1 = strike(1);
        
        if (strike1 == 1) 
        {
            person.frame1 = 10;
            person.strikes++;
        }
        else if (strike1 == 0) 
        {
             half = halfst(1);
             
             if (half == 1) 
             {
                      person.frame1 = 10;
                      person.halfs++;
             }
             else if (half == 0) 
             {
                  cout << "How many pins were knocked down in Frame 1: ";
                  cin >> pins;
                  person.frame1 = pins;
             }
        }
        
        cout << "\n\nFRAME 2:  " << endl;
        strike1 = strike(1);
        
        if (strike1 == 1) 
        {
            person.frame2 = 10;
            person.strikes++;
        }
        else if (strike1 == 0) 
        {
             half = halfst(1);
             
             if (half == 1) 
             {
                      person.frame2 = 10;
                      person.halfs++;
             }
             else if (half == 0) 
             {
                  cout << "How many pins were knocked down in Frame 2: ";
                  cin >> pins;
                  person.frame2 = pins;
             }
        }
        
        cout << endl << endl;
        cout << "| ";
        cout << person.frame1;
        cout << " | ";
        cout << person.frame2;
        cout << " | ";
        cout << person.frame3;
        cout << " | ";
        cout << person.frame4;
        cout << " | ";
        cout << person.frame5;
        cout << " | ";
        cout << person.frame6;
        cout << " | ";
        cout << person.frame7;
        cout << " | ";
        cout << person.frame8;
        cout << " | ";
        cout << person.frame9;
        cout << " | ";
        cout << person.frame10;
        cout << " |";
        cout << endl << "Strikes: " << person.strikes << "\nSpares: "<< person.halfs << endl << endl << endl;
          
        system("pause");
    }
    How can I get the tenth frame to correctly score though?

  7. #7
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    You might want to look into arrays:
    http://www.cprogramming.com/tutorial/lesson8.html

    This is not everything, but it simplifies it (though..check my numbers...I do not bowl).
    And hopefully gives you some ideas.

    Code:
    #include<iostream>
    
    
    using namespace std;
    
    int main()
    {
    
    
    	int frame[10];
    	int strikes =0;
    	int halfs =0;
    	int total_score =0;
    	int score;
    
    
    	cout << "For each frame enter the score, if you got a strike enter '99', a half enter '55'" << endl;
    
    	for (int indx = 0; indx < 10; indx++)
    	{
    
    		cout << "Enter score for frame " << (indx+1) << " : " ;
    		cin >> score;
    
    		if (score == 99)
    		{
    			strikes++ ;
    			frame[indx] = 10;
    			
    		}
    
    
    		if (score == 55)
    		{	
    			halfs++;
    			frame[indx] = 5; //not sure what a half is...I do not bowl
    		}
    
    		
    	
    		total_score = (total_score + frame[indx]);
    		cout << endl;
    	
    
    
    	}
    
    
    	cout << "Number of strikes:" << strikes << " Number of halfs: " << halfs << endl;
    
    	cout << "Total: " << total_score;
    
    
    	return 0;
    			
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Grading Program Error
    By eun-jin in forum C++ Programming
    Replies: 9
    Last Post: 05-09-2006, 07:45 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 06:49 PM
  3. Help required! Bowling Assignment.
    By Pacino in forum C Programming
    Replies: 22
    Last Post: 12-08-2005, 11:55 AM
  4. A Different Bowling Program
    By Mike56p in forum C Programming
    Replies: 3
    Last Post: 12-08-2005, 08:47 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21