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?