HOME TASK:
1. Write a program that reads (fictitious) student test scores in the range 0
through 100 and print the following statistics to two decimal places:
The average (mean) score.
The student with the highest score.
The student with the lowest score.
The number of students whose score equal or exceed the average.
For each student:
The difference between the average score and the student’s score (this can
be either positive or negative).
The grade letter where
A is a score of 90 or greater.
B is a score of 80 through 89.99.
C is a score of 70 through 79.99
D is a score of 60 through 69.99
E is a score of less than 60.
PROGRAM:
import [Link];
public class Lab6 {
public static void main(String[] args) {
[Link]("****STUDENT MARKSHEET RECORD******");
Scanner obj=new Scanner([Link]);
int totalstu;
double sum=0;
int max=0;
int min=0;
int i;
[Link]("Enter total Number of student in your List ?");
totalstu=[Link]();
int roll[]=new int[totalstu];
double marks[]=new double[totalstu];
[Link]("*****************");
for( i=0;i<totalstu;i++)
{
[Link]("Roll Number and Marks of Following Students are : ");
roll[i]=[Link]();
marks[i]=[Link]();}
// [Link]("Calculating Sum !");
for( i=0;i<totalstu;i++){
sum=sum+marks[i];}
// [Link]("Calculating Average Of result !");
double avg=sum/totalstu;
// [Link]("Calculating Difference between avg score and student
score ! ");
double[] dis=new double[totalstu];
for( i=0;i<totalstu;i++) {
dis[i]=marks[i]-avg;}
// [Link]("Finding Maximum Score!");
for( i=0;i<totalstu;i++){
if(marks[max]>marks[i]){
//marks[max]=marks[i];
max=i;}}
for( i=0;i<totalstu;i++){
if(marks[min]<marks[i]){
//marks[min]=marks[i];
min=i;}}
// [Link]("Finding student Scoring higghest then Average !");
int more=0;
for( i=0;i<totalstu;i++){
if(marks[i]>avg){
more++;}}
// [Link]("Finding Grade !");
String []grade=new String[totalstu];
for( i=0;i<totalstu;i++){
if(marks[i]>=90){
grade[i]=" Got A grade";}
else if(marks[i]>=80 && marks[i]<=89.99){
grade[i]=" Got B grade ";}
else if(marks[i]>=70 && marks[i]<=79.99){
grade[i]="Got C grade ";}
else if(marks[i]>=60 && marks[i]<=69.99)
{
grade[i]="Got D grade";
}
elsegrade[i]="Got E grade";
[Link]("Roll Number + Score + difference + grade ----->"+roll[i]
+" ,"+marks[i]+", "+dis[i]+", "+grade[i]);}
[Link]("Average of total Score of student is : "+avg);
[Link](" Low Scoring Student : "+marks[max]);
[Link](" High Scoring Student : "+marks[min]);
[Link]("Number of Student above Average score is :"+more);
}}
OUTPUT: