Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help Correct my code: its not Input 2 5 , 7 5 , - 1 5 , 1 0 , 2 0 , 3 0
Help Correct my code: its not
Input
Your output
Enter a grade: Enter a grade: Enter a grade: Number of Grades Maximum Exam Grade
Minimum Exam Grade
Enter a grade :
Enter a grade :
Enter a grade :
Number of Grades
Maximum Grade
Minimum Grade
Enter a grade :
Enter a grade :
Enter a grade :
Enter a grade:
Enter a grade : d
Enter a grade :
Enter a grade :
Enter a grade :
Enter a grade :
Enter a grade :
Enter a grade :
Enter a grade :
Number of Grades
Maximum Grade
Expected output
Minimum Grade package Grades;
import java.util.Arrays;
import java.util.Scanner;
public class Grades
Studying values from the consumer
public static int readGrades
Scanner read new ScannerSystemin;
System.out.printInput the number of grades: ;
int length read.nextInt;
int grades new intlength;
for int i ; i length; i
System.out.printInput i th grade: ;
int grade read.nextInt;
gradesi grade;
read.close;
return grades;
Calculating the sum of grades in the array
public static int sumint arr
int sum ;
for int i ; i arr.length; i
sum sum arri;
return sum;
Calculating the sum of grades at the first and last index
public static int sumint arr, int firstIndex, int lastIndex
return arrfirstIndex arrlastIndex;
Calculating the average of grades in the array
public static double averageint arr
int sum ;
for int i ; i arr.length; i
sum sum arri;
return double sum arr.length;
Finding the maximum grade in the array of grades
public static int maxValueint arr
int max arr;
for int i ; i arr.length; i
if max arri
max arri;
return max;
Finding the minimum grade in the array of grades
public static int minValueint arr
int min arr;
for int i ; i arr.length; i
if min arri
min arri;
return min;
Main approach
public static void mainString args
int arr;
arr readGrades;
System.out.printlnSum: sumarr;
System.out.printlnSum of the first index and last index values: sumarr arr.length ;
System.out.printlnAverage of grades: averagearr;
System.out.printlnMaximum Grade: maxValuearr;
System.out.printlnMinimum Grade: minValuearr;
For example, if the input is:
The output will be:
Enter a grade:
Enter a grade:
Enter a grade:
Number of Grades
Maximum Exam Grade
Minimum Exam Grade
Enter a grade:
Enter a grade :
Enter a grade:
Enter a grade:
Enter a grade :
Enter a grade:
Enter a grade:
Enter a grade :
Enter a grade:
Enter a grade:
Enter a grade:
Enter a grade :
Number of Grades
Maximum Exam Grade
Minimum Exam Grade
Enter a grade:
Enter a grade:
Enter a grade :
Enter a grade :
Enter a grade:
Enter a grade:
Enter a grade:
Enter a grade:
Enter a grade:
Enter a grade :
Enter a grade :
Enter a grade :
Enter a grade :
Enter a grade:
Number of Grades
Maximum Exam Grade
Minimum Exam Grade
Enter a grade:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started