Notification texts go here Contact Us Buy Now!

Complete the code segment to help Ragav , find the highest mark and average mark secured by him in "s" number of subjects.

Complete the code segment to help Ragav , find the highest mark and average mark secured by him in "s" number of subjects.

 import java.util.Scanner;

public class Exercise1_5{

    public static void main(String[] args) {

Scanner input = new Scanner(System.in);

         double mark_avg;

         int result;

         int i;

         int s;

      //define size of array

       s = input.nextInt();

     //The array is defined "arr" and inserted marks into it.

      int[] arr = new int[s];   

      for(i=0;i<arr.length;i++)

  {

arr[i]=input.nextInt();

        }

//Initialize maximum element as first element of the array.  

   //Traverse array elements to get the current max.

   //Store the highest mark in the variable result.

   //Store average mark in avgMarks.

int sum=0;

  result = arr[0];


for(i=0;i<arr.length;i++)

{

      if(arr[i]>result)

        {

          result = arr[i];

        }

      sum = sum+arr[i];

     }


mark_avg = sum/s;


System.out.println(result);

System.out.print(mark_avg);

}

}

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.