Java Program For Finding First And Second Highest Scores

package array; public class gratest_value { public static void main(String[] args) { int[]marks= {75,78,76,67,95}; String[]subjects={"tamil","english","maths","science","social"}; int first_highscore=0,second_highscore=0; for(int i=0;i first_highscore) { second_highscore=first_highscore; first_highscore=marks[i]; } else if(marks[i]>second_highscore){ second_highscore=marks[i]; } } System.out.println("first highest score is:"+first_highscore); System.out.println("second highest score is:"+second_highscore); } } ......................................................................... OUTPUT: first highest score is:95 second highest score is:78

Feb 20, 2025 - 16:43
 0
Java Program For Finding First And Second Highest Scores
package array;

        public class gratest_value {
            public static void main(String[] args) {    

        int[]marks= {75,78,76,67,95};
        String[]subjects={"tamil","english","maths","science","social"};
        int first_highscore=0,second_highscore=0;
        for(int i=0;i first_highscore) {
               second_highscore=first_highscore;
               first_highscore=marks[i];    
            }
            else if(marks[i]>second_highscore){
                second_highscore=marks[i];
            }

        }
        System.out.println("first highest score is:"+first_highscore);
        System.out.println("second highest score is:"+second_highscore);






    }
}

.........................................................................

OUTPUT:

first highest score is:95
second highest score is:78