//All this is made with the knowledge of C++ till class 11, so it might seem to be a bit lengthy...
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
struct bat{
char name[26];
int run;
int ball;
float strrate;
int flag;
}bats[11];
struct bowl{
char name[26];
int run;
int overs;
float econ;
int wicket;
}bowls[5];
using namespace std;
void title(void)
{
system("cls");
cout<<"\n\t\tThe CricBoard\n";
cout<<"\t\t_____________\n\n";
}
void benter(bat B[]);
void blenter(bowl B[]);
void bdisplay(void);
void bldisplay(void);
void bedit(int);
void bwedit(int);
int main()
{
punarvichaar: int ch,_ch2;
title();
cout<<"Choose from the below two options (Enter 1 or 2):"
<<"\n\n1. Enter the Batting Statistics first"
<<"\n\n2. Enter the Bowling Statistics first\n\n";
cin>>ch;
if(ch==1)
{ benter(bats); blenter(bowls);
} else if(ch==2)
{ blenter(bowls); benter(bats);
} else goto punarvichaar;
punarvichaar2:
title();
cout<<"What do you want now (select from the below given) : \n"
<<"*You will be returned to this screen after the completion of any of the first two options, select 3 to exit then.\n\n"
<<"\n1. Edit the statistics entered "
<<"\n2. Show the scoreboards"
<<"\n3. Exit\n\n";
cin>>_ch2;
if(_ch2==1) {
punarvichaar3a:
title();
int e_ch,bno;
cout<<"Which of these do you want to edit ?"
<<"\n\n1. Batting"
<<"\n2. Bowling\n\n";
cin>>e_ch;
if(e_ch==1){
cout<<"\n\nEnter the batsman's number/position :\n";
cin>>bno;
bedit(bno);
}
else if(e_ch==2){
cout<<"\n\nEnter the bowler's number :\n";
cin>>bno;
bwedit(bno);
}
else goto punarvichaar3a;
}
else if(_ch2==2)
{
punarvichaar3b:
title();
int e_ch;
cout<<"Which of these do you want to see ?"
<<"\n\n1. Batting"
<<"\n2. Bowling\n\n";
cin>>e_ch;
if(e_ch==1){
bdisplay();
cout<<"\n\nEnter any number to go back...";
int for_delay;
cin>>for_delay;
}
else if(e_ch==2){
bldisplay();
cout<<"\n\nEnter any number to go back...";
int for_delay;
cin>>for_delay; }
else goto punarvichaar3b;
}
else if(_ch2==3) exit(0);
goto punarvichaar2;
return 0;
}
void benter(bat B[])
{
int ch;
title();
cout<<"Now, Enter the details of the batsamen performance :";
for(int i=0;i<11;i++)
{
cout<<"\n\nBatsman no. "<<i+1;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
gets(B[i].name);
cout<<"\nEnter runs scored :"; cin>>B[i].run;
cout<<"\nHow many balls did the batsman play ?"; cin>>B[i].ball;
B[i].strrate=B[i].run*100/B[i].ball;
cout<<"Enter 0 if out, 1 if not out, or, any other if not played :";
cin>>ch;
if(!ch)
B[i].flag=0;
else if(ch==1) B[i].flag=1;
else B[i].flag=2;
}
}
void blenter(bowl W[])
{
title();
cout<<"Now, Enter the details of the bowlers performance :";
for(int i=0;i<5;i++)
{
cout<<"\n\nBowler no. "<<i+1;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
gets(W[i].name);
cout<<"\nEnter runs given :"; cin>>W[i].run;
cout<<"\nHow many overs did the bowler bowl ?"; cin>>W[i].overs;
W[i].econ=W[i].run/W[i].overs;
wrong:
cout<<"\nNumber of wickets taken by the bowler :";
cin>>W[i].wicket;
if(W[i].wicket>10) {
cout<<"Wrong detail entered, try again...\n\n"; goto wrong; }
}
}
void bedit(int m)
{ int n=m-1,ch;
cout<<"\n__________________________________________________"
<<"\n\nBatsman no. "<<m;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
cin.getline(bats[n].name,26);
cout<<"\nEnter runs scored :"; cin>>bats[n].run;
cout<<"\nHow many balls did the batsman play ?"; cin>>bats[n].ball;
bats[n].strrate=(float)(bats[n].run*100/bats[n].ball);
cout<<"Enter 0 if out, 1 if not out, or, any other if not played :";
cin>>ch;
if(!ch)
bats[n].flag=0;
else if(ch==1) bats[n].flag=1;
else bats[n].flag=2;
}
void bwedit(int m)
{ int n=m-1,ch;
cout<<"\n__________________________________________________"
<<"\n\nBowler no. "<<m;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
cin.getline(bowls[n].name,26);
cout<<"\nEnter runs given :"; cin>>bowls[n].run;
cout<<"\nHow many overs did the bowler bowl ?"; cin>>bowls[n].overs;
bowls[n].econ=(float)(bowls[n].run/bowls[n].overs);
wrong:
cout<<"\nNumber of wickets taken by the bowler :";
cin>>bowls[n].wicket;
if(bowls[n].wicket>10) {
cout<<"Wrong detail entered, try again...\n\n"; goto wrong; }
}
void bdisplay(void)
{
title();
for(int i=0;i<11;i++)
{
cout<<"\n\nBatsman no. "<<i+1;
cout<<"\n_____________\n"<<"\nName : "<<bats[i].name;
cout<<"\nRuns scored :"<<bats[i].run;
cout<<"\nBalls Played : "<<bats[i].ball;
bats[i].strrate=(float)(bats[i].run*100/bats[i].ball);
cout<<"\nStrike Rate : "<<bats[i].strrate;
cout<<"\nPresent State : ";
if(!bats[i].flag) cout<<"Out";
else if(bats[i].flag==1) cout<<"Not Out";
else cout<<"Didn't Play";
}
}
void bldisplay(void){
title();
for(int i=0;i<5;i++)
{
cout<<"\n\nBowler no. "<<i+1;
cout<<"\n_____________\n"<<"\nName : "<<bowls[i].name;
cout<<"\nRuns given : "<<bowls[i].run;
cout<<"\nOvers Bowled : "<<bowls[i].overs;
bowls[i].econ=(float)(bowls[i].run/bowls[i].overs);
cout<<"\nEconomy of bowler : "<<bowls[i].econ;
cout<<"\nNumber of wickets taken by the bowler : "<<bowls[i].wicket;
}
}
//You may want to share this if its good @_@
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
struct bat{
char name[26];
int run;
int ball;
float strrate;
int flag;
}bats[11];
struct bowl{
char name[26];
int run;
int overs;
float econ;
int wicket;
}bowls[5];
using namespace std;
void title(void)
{
system("cls");
cout<<"\n\t\tThe CricBoard\n";
cout<<"\t\t_____________\n\n";
}
void benter(bat B[]);
void blenter(bowl B[]);
void bdisplay(void);
void bldisplay(void);
void bedit(int);
void bwedit(int);
int main()
{
punarvichaar: int ch,_ch2;
title();
cout<<"Choose from the below two options (Enter 1 or 2):"
<<"\n\n1. Enter the Batting Statistics first"
<<"\n\n2. Enter the Bowling Statistics first\n\n";
cin>>ch;
if(ch==1)
{ benter(bats); blenter(bowls);
} else if(ch==2)
{ blenter(bowls); benter(bats);
} else goto punarvichaar;
punarvichaar2:
title();
cout<<"What do you want now (select from the below given) : \n"
<<"*You will be returned to this screen after the completion of any of the first two options, select 3 to exit then.\n\n"
<<"\n1. Edit the statistics entered "
<<"\n2. Show the scoreboards"
<<"\n3. Exit\n\n";
cin>>_ch2;
if(_ch2==1) {
punarvichaar3a:
title();
int e_ch,bno;
cout<<"Which of these do you want to edit ?"
<<"\n\n1. Batting"
<<"\n2. Bowling\n\n";
cin>>e_ch;
if(e_ch==1){
cout<<"\n\nEnter the batsman's number/position :\n";
cin>>bno;
bedit(bno);
}
else if(e_ch==2){
cout<<"\n\nEnter the bowler's number :\n";
cin>>bno;
bwedit(bno);
}
else goto punarvichaar3a;
}
else if(_ch2==2)
{
punarvichaar3b:
title();
int e_ch;
cout<<"Which of these do you want to see ?"
<<"\n\n1. Batting"
<<"\n2. Bowling\n\n";
cin>>e_ch;
if(e_ch==1){
bdisplay();
cout<<"\n\nEnter any number to go back...";
int for_delay;
cin>>for_delay;
}
else if(e_ch==2){
bldisplay();
cout<<"\n\nEnter any number to go back...";
int for_delay;
cin>>for_delay; }
else goto punarvichaar3b;
}
else if(_ch2==3) exit(0);
goto punarvichaar2;
return 0;
}
void benter(bat B[])
{
int ch;
title();
cout<<"Now, Enter the details of the batsamen performance :";
for(int i=0;i<11;i++)
{
cout<<"\n\nBatsman no. "<<i+1;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
gets(B[i].name);
cout<<"\nEnter runs scored :"; cin>>B[i].run;
cout<<"\nHow many balls did the batsman play ?"; cin>>B[i].ball;
B[i].strrate=B[i].run*100/B[i].ball;
cout<<"Enter 0 if out, 1 if not out, or, any other if not played :";
cin>>ch;
if(!ch)
B[i].flag=0;
else if(ch==1) B[i].flag=1;
else B[i].flag=2;
}
}
void blenter(bowl W[])
{
title();
cout<<"Now, Enter the details of the bowlers performance :";
for(int i=0;i<5;i++)
{
cout<<"\n\nBowler no. "<<i+1;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
gets(W[i].name);
cout<<"\nEnter runs given :"; cin>>W[i].run;
cout<<"\nHow many overs did the bowler bowl ?"; cin>>W[i].overs;
W[i].econ=W[i].run/W[i].overs;
wrong:
cout<<"\nNumber of wickets taken by the bowler :";
cin>>W[i].wicket;
if(W[i].wicket>10) {
cout<<"Wrong detail entered, try again...\n\n"; goto wrong; }
}
}
void bedit(int m)
{ int n=m-1,ch;
cout<<"\n__________________________________________________"
<<"\n\nBatsman no. "<<m;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
cin.getline(bats[n].name,26);
cout<<"\nEnter runs scored :"; cin>>bats[n].run;
cout<<"\nHow many balls did the batsman play ?"; cin>>bats[n].ball;
bats[n].strrate=(float)(bats[n].run*100/bats[n].ball);
cout<<"Enter 0 if out, 1 if not out, or, any other if not played :";
cin>>ch;
if(!ch)
bats[n].flag=0;
else if(ch==1) bats[n].flag=1;
else bats[n].flag=2;
}
void bwedit(int m)
{ int n=m-1,ch;
cout<<"\n__________________________________________________"
<<"\n\nBowler no. "<<m;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
cin.getline(bowls[n].name,26);
cout<<"\nEnter runs given :"; cin>>bowls[n].run;
cout<<"\nHow many overs did the bowler bowl ?"; cin>>bowls[n].overs;
bowls[n].econ=(float)(bowls[n].run/bowls[n].overs);
wrong:
cout<<"\nNumber of wickets taken by the bowler :";
cin>>bowls[n].wicket;
if(bowls[n].wicket>10) {
cout<<"Wrong detail entered, try again...\n\n"; goto wrong; }
}
void bdisplay(void)
{
title();
for(int i=0;i<11;i++)
{
cout<<"\n\nBatsman no. "<<i+1;
cout<<"\n_____________\n"<<"\nName : "<<bats[i].name;
cout<<"\nRuns scored :"<<bats[i].run;
cout<<"\nBalls Played : "<<bats[i].ball;
bats[i].strrate=(float)(bats[i].run*100/bats[i].ball);
cout<<"\nStrike Rate : "<<bats[i].strrate;
cout<<"\nPresent State : ";
if(!bats[i].flag) cout<<"Out";
else if(bats[i].flag==1) cout<<"Not Out";
else cout<<"Didn't Play";
}
}
void bldisplay(void){
title();
for(int i=0;i<5;i++)
{
cout<<"\n\nBowler no. "<<i+1;
cout<<"\n_____________\n"<<"\nName : "<<bowls[i].name;
cout<<"\nRuns given : "<<bowls[i].run;
cout<<"\nOvers Bowled : "<<bowls[i].overs;
bowls[i].econ=(float)(bowls[i].run/bowls[i].overs);
cout<<"\nEconomy of bowler : "<<bowls[i].econ;
cout<<"\nNumber of wickets taken by the bowler : "<<bowls[i].wicket;
}
}
//You may want to share this if its good @_@
Comments
Post a Comment
You are free to leave any kind of suggestion, or improvement. It doesn't require you to sign in either.