Answer to Question #8866 in Java | JSP | JSF for Wilfred

Question #8866
Your lecturer wishes to store the exam marks for java, and perform an analysis of the marks. The marks are expressed as a percentage. There are 15 students that wrote the exam. write the java program that will input the marks for each student and store in an array called Supp. The input must be validated before being stored. Also determine and display the highest and lowest mark. the inputs are: 15,27,38,2,98,42,87,92,99,13,5,72,67,2,1. This is for an assignment and its really urgent, if you could please help me. thanx
Expert's answer
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
& Scanner in = new Scanner(;
& int n;
& System.out.print("Enter number of students: ");
& n = in.nextInt();
& int []supp = new int[n];
& System.out.print("Enter "+n+" marks: ");
& for (int i=0;i<n;i++){
& double temp;
& temp=in.nextDouble();
& if ((temp%1!=0)||(temp<0)){
& System.out.println("Mark error "+temp+" try again!");
& i--;
& }
& else supp[i]=(int)temp;
& }
& int max=0;
& int min=Integer.MAX_VALUE;
& for (int i=0;i<n;i++){
& if (supp[i]>max)
& max=supp[i];
& if (supp[i]<min)
& min=supp[i];
& }
& System.out.println("The lowest mark: "+min);
& System.out.println("The higest mark: "+max);


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


Assignment Expert
28.04.12, 18:08

You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!

28.04.12, 18:03

Thanx it helped alot

Leave a comment

Ask Your question

New on Blog