Computer Science, asked by reenaverma2110, 4 months ago

Write a java program which will input the number of students in a class. Input the
marks of all students and find:
1. Average marks obtained in the class.
2. Highest marks obtained in the class

Answers

Answered by gulabraut1669
0

Answer:

1 one is the answer of the Question

Explanation:

Answered by BrainlyProgrammer
5

Question:-

  • Write a java program which will input the number of students in a class. Input the marks of all students and find:
  1. Average marks obtained in the class.
  2. Highest marks obtained in the class

Code Language:-

  • Java

Code:-

package Coder;

import java.util.*;

public class Marks

{

public static void main (String ar [])

{

Scanner sc=new Scanner (System.in);

System.out.println("No. of students?");

int s=sc.nextInt();

int k=0,a=0;

double avg=0;

for(int i=1;i<=s;i++)

{

System.out.println("Enter marks");

int m=sc.nextInt();

k+=m;

if(m>a)

a=m;

}

avg=k/s; //Finding average

System.out.println("Average="+a+"\nHighest Mark="+a);

}

}

Variable Description:-

  1. i:- loop variable
  2. s:- to accept no. of students
  3. k:- to store sum of marks
  4. a:- to store highest mark
  5. avg:- to calculate Average

•Output Attached.

Attachments:
Similar questions