-
Notifications
You must be signed in to change notification settings - Fork 3
/
Cricket.java
51 lines (27 loc) · 893 Bytes
/
Cricket.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//To find cricket score and run rate
import java.lang.*;
import java.util.*;
class Cricket
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("ODI MATCH SCORECARD");
System.out.println("Enter the name of team batting first: ");
String team1=sc.next();
int score1=0;
float rr1=0;
for(int i=1;i<=11;i++) //Assuming that all 11 players batted
{
System.out.print("Enter player name: ");
String nm1=sc.next();
System.out.print("Enter runs scored by player: ");
int runs1=sc.nextInt();
score1=runs1+score1;
rr1=(float)((score1))/50;
}
System.out.println("Total runs: "+score1);
System.out.println("Run rate: "+rr1);
System.out.println(team1+" scored "+score1+" runs at run rate "+rr1);
}
}