### Baseball Program

oh god whats wrong

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214`` ``````#include using namespace std; int firstInning(); int nextInning(); int firstInning() { cout<<"\n\n****** Visitor Team now at Bat Home Team in the Field ********\n\n"; int batter = 1, outs = 0, balls = 0, strikes = 0 , runs = 0, hits = 0; char call, choice; do { cout<<"Inning Status Batter # "<>call; if ((call == 'S')||(call == 's')) { strikes += 1; if (strikes == 3) { batter += 1; outs += 1; strikes = 0; if (outs == 3) { cout<<" Three Outs !!!"; cout<<"\n\nIs there another half inning (Y/N) "; cin>>choice; if ((choice == 'Y')||(choice == 'y')) { nextInning(); } } } } else if ((call == 'B')||(call == 'b')) { balls +=1; if ( balls == 4) { batter += 1; balls = 0; } } else if ((call == 'F')||(call = 'f')&&(strikes > 2)) { strikes += 1; } else if ((call == 'F')||(call = 'f')&&(strikes = 2)) { strikes = 2; } else if ((call == 'H')||(call == 'h')) { batter += 1; balls = 0; strikes = 0; } else if ((call == 'O')||(call = 'o')) { outs += 1; if (outs == 3) { cout<<" Three Outs !!!"; cout<<"\n\nIs there another half inning (Y/N) "; cin>>choice; if ((choice == 'Y')||(choice == 'y')) { nextInning(); } } } else if ((call == 'R')||(call == 'r')) runs += 1; else cout<<"******** Invaled Please enter S,B,F,G,H,O or R"; } while (outs < 3); } int nextInning() { cout<<"\n\n****** Home Team now at Bat Visitor Team in the Field ********\n\n"; int batter = 1, outs = 0, balls = 0, strikes = 0 , runs = 0, hits = 0; char call, choice; do { cout<<"Inning Status Batter # "<>call; if ((call == 'S')||(call == 's')) { strikes += 1; if (strikes == 3) { batter += 1; outs += 1; strikes = 0; if (outs == 3) { cout<<" Three Outs !!!"; cout<<"\n\nIs there another half inning (Y/N) "; cin>>choice; if ((choice == 'Y')||(choice == 'y')) { firstInning(); } } } } else if ((call == 'B')||(call == 'b')) { balls +=1; if ( balls == 4) { batter += 1; balls = 0; } } else if ((call == 'F')||(call = 'f')&&(strikes > 2)) { strikes += 1; } else if ((call == 'F')||(call = 'f')&&(strikes = 2)) { strikes = 2; } else if ((call == 'H')||(call == 'h')) { batter += 1; balls =0; strikes = 0; } else if ((call == 'O')||(call = 'o')) { outs += 1; if (outs == 3) { cout<<" Three Outs !!!"; cout<<"/n\nIs there another half inning (Y/N) "; cin>>choice; if ((choice == 'Y')||(choice == 'y')) { firstInning(); } } } else if ((call == 'R')||(call == 'r')) runs += 1; else cout<<"******** Invaled Please enter S,B,F,G,H,O or R"; } while (outs < 3); } int main() { cout<<"Boy's of Summer 2013\n"; cout<<"Umpire's Assistant At Your Service"; cout<<"\n\nThe Item Codes are as follows: "; cout<<"\nCode Description Code Description"; cout<<"\nS Strike H Hit"; cout<<"\nB Ball O Out"; cout<<"\nF Foul Ball R Run in"; cout<<"\nG Game Canceled"; firstInning(); cin.get(); cin.get(); return 0; } ``````
How do you know it's wrong?
Have you ever tried using the "switch" method instead of using else-ifs so much?

It would make your code much clearer.
Topic archived. No new replies allowed.