input the marks for each student and store in an array called supp.the input must be validated before being stored :input are 15 27 38 2 98 42 87 92 99 13 5 72 67 2 1
my qestion is how do i determine and display the highest and lowest mark
1
Expert's answer
2012-04-28T09:45:51-0400
import java.util.Scanner;
public class Main { public static void main(String[] args) { & Scanner in = new Scanner(System.in); & 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); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment