Monday, 10 August 2020

Input runs scored in a cricket and display the highest

 Input runs scored in a cricket and display the highest


In this java program we are going to see the runs scored by 11 batsman
in a cricket match and display the highest score among them.
so first read the runs scored by 11 batsman in a match and find the highest score.



import java.util.*;
class Highest{
 public static void main(String args[]){
    int score[]=new int[11];  
    Scanner sc=new Scanner(System.in);
    //reading the runs scored by individual players
    for(int i=0;i<11;i++){
        System.out.println("Enter runs scored by player "+i+1+".");
        score[i]=sc.nextInt();
    }
    //displaying the runs scored by individual players
    for(int i=0;i<11;i++){
       System.out.println("Runs scored by player"+i+1+" is "+score[i]);
    }
    //finding maximum
    int max=0;
    for(int i=0;i<11;i++){
       if(score[i]>max)
           max=score[i];
       }
    System.out.println("Highest scored runs = "+max);
    }
}

 

output:

 

No comments:

Post a Comment