Skip to main content

The CricBoard - A C++ Project

//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 @_@

Comments

Popular posts from this blog

Using 'ls' command as a replacement of 'find'

Advantage over find - Actually not probably in terms of speed, but... only point of this is that it's an observation, but... you can do like 'search only in' */*/*Programs* , /*/*Programs*/* , this may compensate the extra time took by using two commands 1. To search in current folder only (1 level... only this folder, no subfolder)     Type... ls | grep Search_Term 2. To search in current folder only (till level 2... this folder + subfolder)     Type... ls * | grep Search_Term #ls and ls * are NOT same! 3. To search in current folder only (till level 3... this folder + subfolder + subfolder)     Type... ls */* | grep Search_Term 4. To search in current folder only (till level 4... this folder + subfolder + subfolder + subfolder)     Type... ls */*/* | grep Search_Term ... and so on... FORMULA - To search till 'n' level (considering current folder as 1)... go till (n-1) stars If wanting to search whole disk... better type stars, like this... ls * ** *** **** *****

AP, GP Generator (using Linked List)

//Future advancements-> add save as file, in text or in a database option (for the sequences) //                      add more series to this //Programmer - Aditya Gupta #include<iostream> #include<stdlib.h> #include<math.h> //#include<fstream> //reqd when save support is added to this! using namespace std; struct Node{ int data; Node* next; }; void inline title(void){ system("cls"); cout<<"\tNAMASTE!...\n\nProgram-AP,GP Generator\nPrograammer - MR. ADITYA GUPTA (TEChY 3)\n\n"; } class List{ //NOTE: I HAVE REMOVED ALL COMMENTS, REFER TO THE LINKED LIST TEMPLATE FOR DETAILED COMMENTS             //here only generator specific comments are there, and that too which are not in template Node *top,*rear; public: void Push(int dat); int isempty(); int search(int dat); int noofelements(); void Pop(); //CAUTION- will decrease number of terms by 1 each time it runs, and pushing the last element again will be same

More_Inferences_in_C++(1Aug'19-16thOct'19)

Programmer/Tester- Aditya Gupta (aka Techy3.5 :-) I used g++ to compile these on linux 1. Type casting of floating point numeral to integer (either automatic or by type casting)- Conversion of floating point to integer is by taking the GIF (Greatest Integer Funtion) and NOT ROUNDING OFF Greatest Integer Function(Maths,12th) it gives the integer part when the original number is written as integer+fractional part (where fractional part is less than 1 but positive) 2. NEsted MultiLine Comment [actually wont work as expected?!] if you do this in C++.... /*  blah /*blah blah blah*/ blah*/ the last blah will be visible to the compiler!!! (Inference- Multiline-Comment ends whenever */ is encountered, no matter where!!)NEsted MultiLine Comment 3. Size of various types (of C++) on 'Linux' Mint - (and same as in later versions of windows, and most PCs nowadays) char - 1 int - 4  (and: short - 2, unsigned long - 8) long long - 8 float - 4 double - 8 (and: lo