Student Grade Report Java Program
Java Code:
import java.util.Scanner;
public class grade {
public static void average(int[] array){
double sum=0;
int count=0;
double average=0;
for(int i=0; i<array.length; i++){
sum+=array[i];
count++;
}
average=sum/count;
System.out.print(average);
}
public static void main(String[] args)
{
Scanner
input = new Scanner(System.in);
System.out.print("Enter the
number of students: ");
int NoS =
input.nextInt();
String[]
names = new String[NoS];
int[] array = new int[NoS];
int i=0;
int Score;
while(i<NoS){
System.out.print("Enter the
test Score: ");
Score
= input.nextInt();
if(Score<0 || Score
>100){
System.out.print("incorrect
score, Re-enter the score-(must be positive and between 0 to 100):");
Score
= input.nextInt();
}
array[i]=Score;
System.out.print("Enter the
Student Name: ");
String
name = input.next();
names[i]=name;
i++;
}
int h=array[0];
int high=0;
int j=0;
while(j<array.length){
if(h>=array[j]){
high=
h;
j++;
}
else{
h=array[j];
}
}
int l=array[0];
int low=0;
int k=0;
while(k<array.length){
if(l<=array[k]){
low=l;
k++;
}
else{
l=array[k];
}
}
int ind=0;
int n=0;
int m=0;
while(ind<array.length){
if(array[ind]==high){
n=ind;
}
if(array[ind]==low){
m=ind;
}
ind++;
}
System.out.print("\n");
System.out.println("Test Analysis
Program");
System.out.println("High score:
"+
names[n] +":
"+
high);
System.out.println("Low score:
"+
names[m] +":
"+
low);
System.out.print("Class average
is"
+ "
");
average(array);
int grade=0;
int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
while(grade<array.length){
if(array[grade]>=90){
a+=1;
}
if(array[grade]>=80
&& array[grade]<90){
b+=1;
}
if(array[grade]>=70
&& array[grade]<80){
c+=1;
}
if(array[grade]>=60
&& array[grade]<70){
d+=1;
}
if(array[grade]>=0
&& array[grade]<60){
e+=1;
}
grade++;
}
System.out.print("\n");
System.out.println("Grade
Distribution");
System.out.println("90-100:
" +
a);
System.out.println("80-89: " + b);
System.out.println("70-79: " + c);
System.out.println("60-69: " + d);
System.out.println("Below
60:"
+ e);
}
}