Computer Science, asked by GiyuuTomioka, 2 months ago

Write a program in java to store the computer marks of 75 students and find out the position of the highest and lowest marks.​

Answers

Answered by anindyaadhikari13
7

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - Java.

import java.util.Scanner;

public class Brainly{

   public static void main(String args[]){

       Scanner sc=new Scanner(System.in);

       System.out.println("Enter marks of 75 students...");

       int n=75,i;

       int a[]=new int[n];

       for(i=0;i<n;i++){

           System.out.print("["+(i+1)+"] = ");

           a[i]=sc.nextInt();

       }

       int max=a[0],min=a[0];

       for(int x:a){

           if(x>max)

               x=max;

           if(x<min)

               min=x;

       }

       System.out.print("Student(s) who got the highest marks is at position(s): ");

       for(i=0;i<n;i++){

           if(a[i]==max)

               System.out.print(i+1+" ");

       }

       System.out.print("\nStudent(s) who got the lowest marks is at position(s): ");

       for(i=0;i<n;i++){

           if(a[i]==min)

               System.out.print(i+1+" ");

       }

   }

}

\textsf{\large{\underline{Logic}:}}

  1. Accept the marks of 75 students and store them in array.
  2. Now calculate the highest and lowest marks from the array.
  3. Use a loop to transverse through array elements. If the array element is equal to highest or lowest marks, display its index.
Attachments:

anindyaadhikari13: Thanks for the brainliest :)
Similar questions