Professional Documents
Culture Documents
Assignment Array ERIANALIM234
Assignment Array ERIANALIM234
for array.
* I need to write a program that reads number of students in a class, student’s name, and
student’s marks.
* Display the maximum marks along with their names and their
index location respectively and the total of students who gained the maximum
marks.
* Display the minimum marks along with their names and their
index location respectively and the total of students who gained the minimum
marks.
*/
// Import statement
import java.util.Scanner;
// Class header
// Main method
//Declare variables
double maxmarks=-999999;
double minmarks=999999;
double sum=0.0;
double totalhighest=0.0;
double totallowest=0.0;
double average=0.0;
while(i<name.length) //C
System.out.print("\n");
name[i]=sc.next();
marks[i]=sc.nextDouble();
sum=sum+marks[i];
i=i+1; //U
} // end repeat
i=0; //I
while(i<marks.length) //C
{
if(marks[i]>maxmarks)
maxmarks=marks[i];
//end if
i=i+1; //U
} //end repeat
i=0; //I
while(i<marks.length) //C
if(marks[i]<minmarks)
minmarks=marks[i];
//end if
i=i+1; //U
} //end repeat
// 3rd looping to find the names of the highest marks and frequency of students who got the
highest mark
System.out.print("\n");
i=0; // I
while(i<marks.length) //C
if(marks[i] == maxmarks)
totalhighest=totalhighest + 1;
}
//end if
i=i+1; //U
} //end repeat
System.out.print("\n");
// 4th looping to find the names of the lowest marks and frequency of students who got the
lowest mark
i=0; // I
while(i<marks.length) //C
if(marks[i] == minmarks)
totallowest=totallowest + 1;
//end if
i=i+1; //U
}//end repeat
System.out.print("\n");
System.out.println( "The number of student(s) obtained the lowest marks= "+ minmarks+ "\n");