Computer Science, asked by vipulchoudhary35, 3 months ago

Write a java program that inputs number of runs made by a cricket

player on each ball. Entering runs as -1 should display the message

that player is out. Finally it displays the number of runs made and

balls played by the player.​

Answers

Answered by BubblySnowFake
2

Answer:

import java.io.*;

class CricketPlayer

{

int pcode,run,notout;

String name;

int iplayed;

CricketPlayer(){ }

CricketPlayer(int pcode1,String pname,int run1,int iplayed1,int notout1)throws IOException

{

pcode=pcode1;

name=pname;

run=run1;

iplayed=iplayed1;

notout=notout1;

}

public double average (String name1)

{

double avg=0;

if(name.equals(name1))

{

avg=(double)run/(double)iplayed;

return avg;

}

else

return 0;

}

public double average ()

{

double avg=0;

avg+=(double)run/(double)iplayed;

return avg;

}

}

class Cricket

{

public static void main(String args[])throws IOException

{

int pcode,iplayed,noplayer,notout,runs;

double avg=0,avgall=0;

String name;

BufferedReader br= new BufferedReader (new InputStreamReader(System.in));

System.out.println(“Enter How many Players:=> “);

noplayer=Integer.parseInt(br.readLine());

CricketPlayer s[]=new CricketPlayer[noplayer];

Similar questions