public static int sum(int[] arr) public static int sum(int[] arr, int firstIndex, int lastIndex) public static double average(int[] arr)
How do I input:
public static int readGrades(int[] grades)
public static int sum(int[] arr)
public static int sum(int[] arr, int firstIndex, int lastIndex)
public static double average(int[] arr)
public static int maxValue(int[] arr)
public static int maxValue(int[] arr, int firstIndex, int lastIndex)
public static int indexOfFirstMaxValue(int[] arr)
public static int minValue(int[] arr)
public static int minValue(int[] arr, int firstIndex, int lastIndex)
public static int indexOfFirstMinValue(int[] arr)
public static int numberOfBelowAverageElements(int[] arr)
public static int numberOfAboveAverageElements(int[] arr)
public static void rotateElements(int[] arr)
public static void rotateElements(int[] arr, int rotationCount)
public static void reverseArray(int[] arr)
public static void main(java.lang.String[] args)
into my java code?
code:
import java.util.Scanner;
public class Grades {
public static void main(String[] args) {
//Declare required variables
int grade,count = 0;
int min = 100, max = 0;
//Scanner for user input
Scanner scan = new Scanner(System.in);
//Infinite loop
while(true) {
//Prompt for input
System.out.print("Enter a grade: ");
grade = scan.nextInt();
if(grade<0)
break;
else
count++;
//Keep track of grades
max = Math.max(max, grade);
min = Math.min(min, grade);
}
//Output result
System.out.println("Number of Grades = "+count);
System.out.println("Maximum Exam Grade = "+max);
System.out.println("Minimum Exam Grade = "+min);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps