Computer Science, asked by Anonymous, 8 months ago

Write a program in java to accept the marks of 10 subjects and display the highest and lowest marks obtained using array.​

Answers

Answered by Anonymous
2

\huge\mathrm{Program :-}

import java. util . * ;

class Subject

{

static void main ()

{

Scanner sc = new Scanner(System.in) ;

double marks[] = new double[10] ;

System.out.println (" Enter the marks of 10 subjects : ") ;

for ( int i=0 ; i < marks. legth ; i ++ )

{

System.out.println ( " Enter the marks : " + ( i + 1 )) ;

marks [i] = sc. nextDouble() ;

}

double max = marks[0] , min = marks[0] ;

for ( int i= 0 ; i< marks. length ; i++ )

{

if ( marks[i] > max)

{

max = marks [i] ;

}

if ( marks[i] < min)

{

min = marks[i] ;

}

}

System. out. println (" Highest marks : " + max + " Lowest marks : " + min ) ;

}

}

_____________________________

\huge\mathrm{Output :-}

  • Given in the attachment is the output of the above program
Attachments:
Similar questions