C++ program on Cricket scorecard

0 kartik watwani · January 26, 2015
I have been developing a c++ program on making a cricket scorecard,I have done all the codings without any error but it is not giving up results.The results I want is that I want to update scorecard and see scorecard but after when we write name of 22 players and select any option it again asks for batsman name and says you entered wrong player .I would like to know ,how I would get the results.Here is my code/images/forum/upload/2015-01-26/10247bec849f74db106492cd8475d0eb.png


#include<iostream>
#include<string.h>
using namespace std;
class scorecard{
char batname[11][20];
int runscored[11];
char situation[11][10];
char mode[11][15];
char bowlername[11][20];
float oversplayed[11];
int maiden[11];
int runsgiven[11];
int wicketstaken[11];
public:

void updatebatsman(void);
void updatebowler(void);
void displaybat(void);
void displaybowl(void);
void menu(void);
scorecard()
{for(int n=0;n<12;n++)
   {

    runscored[n]={0};
     oversplayed[n]={0};
 maiden[n]={0};
 runsgiven[n]={0};
 wicketstaken[n]={0};
   }
}




};
int main()
{
    int jb=0;
     scorecard s1;
    int kb;
    s1.menu();
    do
    {
     cout<< "Enter the option"<<endl;
        cout<<"(1) Display batting score"<<endl<<"(2) Display Bowling score"<<endl<<"(3) Update batting score"<<endl;
        cout<<"(4) Update Bowling score"<<endl;
        cin >>kb;
        switch(kb)
        {
            case 1 : s1.displaybat();
                    break;
            case 2 :s1.displaybowl();break;
            case 3:s1.updatebatsman();break;
            case 4:s1.updatebowler();break;
            default:cout<<"Wrong choice";
        }
    }while (jb<1);
}

void scorecard::updatebowler(void)
    {char bowlname[20];
    int str,k,option,overnumbers,maidenumb,uprun,upwicket;
        cout<<"Enter Bowler name:";
        cin.getline(bowlname,20);
    for( k=0;k<11;k++)
      {str=  strcmp(bowlername[k],bowlname);
      if (str== 0)
      {
          cout<<"Menu for Bowler information update "<<endl;
          cout<<"(1) Update Number of overs"<<endl<<"(2) Update maiden overs"<<endl<<"(3) Update runs given"<<endl;
          cout<<"(4) Update wickets taken"<<endl;
          cin >> option;
          switch(option)
          {
              case 1:{cout<<"Enter Numbers of overs to be updated:";
                      cin >>overnumbers;
                      cout<<endl;
                      oversplayed[k]+=overnumbers;
                      break;
                     }
               case 2:{cout <<"Enter the number of maiden overs to be updated:";
                       cin>>maidenumb;
                       cout<<endl;
                       maiden[k]+=maidenumb;
                       break;
                      }
               case 3:{cout <<"Enter the number of runs to be added:";
                       cin>>uprun;
                       cout<<endl;
                       runsgiven[k]+=uprun;
                       break;

                      }
                case 4: {cout<<"Enter number of wickets to be updated:";
                         cin >>upwicket;
                         cout<<endl;
                         wicketstaken[k]+=upwicket;
                        }
                   default:cout<<"wroung choice";

          }
          break;
      }



      }
      if (str!=0)
        cout <<"You entered wrong player."<<endl;

    }



     void scorecard::updatebatsman(void)
    {char batsmaname[20];
    int str,k;
        cout<<"Enter Batsman name:";
        cin.getline(batsmaname,20);
    for( k=0;k<11;k++)
      {str=  strcmp(batname[k],batsmaname);
      if (str== 0)
      {
          cout<<"enter runs scored:";
          cin>>runscored[k];

          cout<<endl<<"enter weather out or not out:";
          cin>>situation[k];
          cout<<endl<<"enter mode(if batsman out) by which batsman was out:";
          cin>>mode[k];
          break;
      }



      }
      if (str!=0)
        cout <<"You entered wrong player."<<endl;

    }
void scorecard::displaybat(void)
{
    cout << "Batsman name"<<'t'<<"Runs scored"<<'t'<<"situation"<<'t'<<"mode"<<endl;
    cout<<endl;
    for(int j=0;j++;j<12)
    {
        cout<<batname[j]<<'t'<<runscored[j]<<'t'<<situation[j]<<'t'<<mode[j]<<endl;
    }
}
void scorecard::displaybowl(void)
{
     cout << "Bowler name"<<'t'<<"overs played"<<'t'<<"maiden overs"<<'t'<<"wicket taken"<<'t'<<"Runs given"<<endl;
    cout<<endl;
    for(int j=0;j++;j<12)
    {
        cout<<bowlername[j]<<'t'<<oversplayed[j]<<'t'<<maiden[j]<<'t'<<wicketstaken[j]<<'t'<<runsgiven[j]<<endl;
    }
}
void scorecard::menu(void)

{
    cout<<"Enter the name of players of batting team"<<endl;
    for (int k=0;k<11;k++)
    {

        cout <<"Enter name of player "<<k+1<<":";
    cin>>batname[k];
    }
    cout <<"Enter the name of players of bowling team"<<endl;
    for (int n=0;n<11;n++)
    {

        cout <<"Enter name of player "<<n+1<<":";
    cin>>bowlername[n];
    }
}

Post a Reply

Replies

Oldest  Newest  Rating
0 c student · January 26, 2015
1. you're using string.h which is not c++
2. i think you should rethink this...

http://i.imgur.com/6xkhtsy.png

you have completely destroyed my terminal.  i don't even know what or how you're accessing things inside my computer and i'm too afraid to ask. nevertheless, it looks brilliant and sorta looks like snow.  magnificent!
0 kartik watwani · January 27, 2015
sir bucky Roberts taught us to use string.h in c++
0 c student · January 27, 2015
you're probably looking for <cstring>.
+1 Jake Scaife · January 27, 2015
Use <string> in c++ <cstring> is a C library.
Make sure you have C++11 or 14 configs enabled in order to have access to all of the functionallity of the string class.

Im 90% sure that string.h is the same as <cstring>, both C style string classes.
0 kartik watwani · January 27, 2015
i used that also but it is not working.please sir
bucky help me
0 c student · January 27, 2015
you need to replace all your string.h functions with the corresponding cstring ones.
0 kartik watwani · January 27, 2015
hey I am not using visual c++ so I dont require cstring functions, please bucky sir help me
  • 1

C++

107,254 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator