help w/ storing/scanning numbers in arrays
im kinda stuck on what to do on this assignment and tried to email my instructor but he didnt respond(were on spring break btw)
but here are my instructions
Enhance / modify the program you created in the previous assignment. Create a class ScanArray. This class should have two methods FindMax and FindMin. Class ScanArray should have a constructor. main should call the constructor, next should use / call the two methods of the object to identify the min and max. Next, main informs the instructor of the minimum grade and maximum grade.
and here is my code from the previous assignment
Code:
import java.util.Scanner;
import java.util.Arrays;
public class Array
{ public static void main(String[] args)
{
//input scanner
Scanner input = new Scanner(System.in);
//Prompt User for midterm1 grades
double[]midTerm1= new double [10];
for (int A = 0; A <midTerm1.length; A++){
System.out.println("Please enter MidTerm1 grade:");
midTerm1[A] = input.nextDouble();
}
System.out.println("Now");
//Prompt User for midterm2 grades
double[]midTerm2=new double[10];
for(int B=0; B<midTerm2.length;B++){
System.out.println("Please enter a MidTerm2 grade:");
midTerm2[B] = input.nextDouble();
}
System.out.println("Now");
//Prompt User for Final Exam grades
double[]finalExam = new double[10];
for(int C = 0; C<finalExam.length; C++){
System.out.println("Please enter a Final Exam grade:");
finalExam[C] = input.nextDouble();
}
double [] grades = new double [10];
for (int i = 0; i < grades.length;i ++){
grades[i] = midTerm1[i] +midTerm2[i]+finalExam[i];
}
double max = 0;
double min = 0;
max = grades[0];
for (int i=1; i<grades.length; i++) {
if (grades[i] > max) {
max = grades[i];
}
}
min = grades[0];
for (int i=1; i<grades.length; i++) {
if (grades[i] < min) {
min = grades[i];
}
}
System.out.print("Your highest test score is: " + max);
System.out.print("Your lowest test score is: " + min);
System.out.print("You have entered following grades for midTerm1: ");
System.out.println(Arrays.toString(mid…
System.out.print("You have entered following grades for midTerm2: ");
System.out.println(Arrays.toString(mid…
System.out.print("You have entered following grades for Final Exam: ");
System.out.println(Arrays.toString(fin…
}
}