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
0
Answer:
1 one is the answer of the Question
Explanation:
Answered by
5
Question:-
- Write a java program which will input the number of students in a class. Input the marks of all students and find:
- Average marks obtained in the class.
- 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:-
- i:- loop variable
- s:- to accept no. of students
- k:- to store sum of marks
- a:- to store highest mark
- avg:- to calculate Average
•Output Attached.
Attachments:
Similar questions