write a program to store the name of 20 students along with their marks obtained in computer applications in the final examination in single dimensional array. Display the name of the student getting the highest marks
Answers
Answered by
0
import java.util.Scanner;
public class Student_Marks
{
public static void main(String[] args)
{
int n, total = 0, percentage;
Scanner s = new Scanner(System.in);
System.out.print("Enter no. of subject:");
n = s.nextInt();
int marks[] = new int[n];
System.out.println("Enter marks out of 100:");
for(int i = 0; i < n; i++)
{
marks[i] = s.nextInt();
total = total + marks[i];
}
percentage = total / n;
System.out.println("Sum:"+total);
System.out.println("Percentage:"+percentage);
}
}
Output:
$ javac Student_Marks.java
$ java Student_Marks
Enter no. of subject:5
Enter marks out of 100:
86
89
91
82
78
Sum:426
Percentage:85
Similar questions
Social Sciences,
2 months ago
Math,
2 months ago
Math,
5 months ago
Biology,
5 months ago
Math,
9 months ago