0% found this document useful (0 votes)
166 views

Array Java 2

The program reads test scores between 0-100 for multiple students. It then calculates and prints: the average score, the student with the highest score, the student with the lowest score, and the number of students above the average. It also prints for each student: their difference from the average, and their letter grade based on their score.

Uploaded by

Anas Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
166 views

Array Java 2

The program reads test scores between 0-100 for multiple students. It then calculates and prints: the average score, the student with the highest score, the student with the lowest score, and the number of students above the average. It also prints for each student: their difference from the average, and their letter grade based on their score.

Uploaded by

Anas Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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 java.util.Scanner;
public class Lab6 {
public static void main(String[] args) {
System.out.println("****STUDENT MARKSHEET RECORD******");
Scanner obj=new Scanner(System.in);
int totalstu;
double sum=0;
int max=0;
int min=0;
int i;
System.out.println("Enter total Number of student in your List ?");
totalstu=obj.nextInt();
int roll[]=new int[totalstu];
double marks[]=new double[totalstu];
System.out.println("*****************");
for( i=0;i<totalstu;i++)
{
System.out.println("Roll Number and Marks of Following Students are : ");
roll[i]=obj.nextInt();
marks[i]=obj.nextDouble();}
// System.out.println("Calculating Sum !");
for( i=0;i<totalstu;i++){
sum=sum+marks[i];}
// System.out.println("Calculating Average Of result !");
double avg=sum/totalstu;
// System.out.println("Calculating Difference between avg score and student
score ! ");
double[] dis=new double[totalstu];
for( i=0;i<totalstu;i++) {
dis[i]=marks[i]-avg;}
// System.out.println("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;}}
// System.out.println("Finding student Scoring higghest then Average !");
int more=0;
for( i=0;i<totalstu;i++){
if(marks[i]>avg){
more++;}}
// System.out.println("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";
System.out.println("Roll Number + Score + difference + grade ----->"+roll[i]
+" ,"+marks[i]+", "+dis[i]+", "+grade[i]);}
System.out.println("Average of total Score of student is : "+avg);
System.out.println(" Low Scoring Student : "+marks[max]);
System.out.println(" High Scoring Student : "+marks[min]);
System.out.println("Number of Student above Average score is :"+more);
}}

OUTPUT:

You might also like