Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For these two inputs I need the answer to look like the pictures above One Input

ID: 3813904 • Letter: F

Question

For these two inputs I need the answer to look like the pictures above


One Input is

The second

I have a program this one but it's not working so please make a new one that works and looks like the EXPECTED OUTPUT! I spent 4 questions already I really hope I don't have to waste all of them on this one question.
This is the program I have you can fix it to look like the expected output or create another one. I WANT THE EXPECTED OUT PUT TO SHOW WHEN THOSE TWO INPUTS ARE ENTERED, SEND A PICTURE OF BOTH INPUTS WORKING! import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class ExamGrades { public static final int MAX_EXAM_GRADES = 100; public static int[] examGrades = new int[MAX_EXAM_GRADES]; public static int numberOfGrades; public static int readExamGrades() { System.out.println("Enter a grade : "); Scanner obj = new Scanner(System.in); int x; int ind = 0;
while ((x = obj.nextInt()) >= 0) { System.out.println("Enter a grade : "); examGrades[ind++] = x; } numberOfGrades = ind; return ind; } public static int sumOfExamGrades() { int sum = 0; for (int i = 0; i < numberOfGrades; i++) { sum += examGrades[i]; } return sum; } public static double averageExamGrade() { return (sumOfExamGrades() * 1d) / (numberOfGrades * 1d); } public static int maxExamGrade() { int max = -1; for (int i = 0; i < numberOfGrades; i++) { max = Math.max(max, examGrades[i]); } return max; } public static int indexOfFirstMaxExamGrade() { int max = examGrades[0]; int ind = 0; for (int i = 1; i < numberOfGrades; i++) { if (examGrades[i] > max) { max = examGrades[i]; ind = i; } } return ind; } public static int minExamGrade() { int min = Integer.MAX_VALUE; for (int i = 0; i < numberOfGrades; i++) { min = Math.min(min, examGrades[i]); } return min; } public static int indexOfFirstMinExamGrade(){ int min = examGrades[0]; int ind = 0; for(int i=1;i<numberOfGrades;i++){ if(examGrades[i]<min){ min = examGrades[i]; ind = i; } } return ind; } public static int numberOfBelowAverageGrades(){ int ans = 0; double avg = averageExamGrade(); for(int i=0;i<numberOfGrades;i++){ if(examGrades[i]<avg){ ans++; } } return ans; } public static int numberOfAboveAverageGrades() { int ans = 0; double avg = averageExamGrade(); for(int i=0;i<numberOfGrades;i++){ if(examGrades[i]>avg){ ans++; } } return ans; } public static void main (String[] args) { readExamGrades(); System.out.println("Number Of Grades = "+numberOfGrades); System.out.println("Maximum Exam Grade = "+maxExamGrade()+" At Index = "+indexOfFirstMaxExamGrade()); System.out.println("Minimum Exam Grade = "+minExamGrade()+" At Index = "+indexOfFirstMinExamGrade()); System.out.println("Number Of Below Average Exam Grades = "+numberOfBelowAverageGrades()); System.out.println("Number Of Above Average Exam Grades = "+numberOfAboveAverageGrades()); System.out.println(""); } } import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class ExamGrades { public static final int MAX_EXAM_GRADES = 100; public static int[] examGrades = new int[MAX_EXAM_GRADES]; public static int numberOfGrades; public static int readExamGrades() { System.out.println("Enter a grade : "); Scanner obj = new Scanner(System.in); int x; int ind = 0;
while ((x = obj.nextInt()) >= 0) { System.out.println("Enter a grade : "); examGrades[ind++] = x; } numberOfGrades = ind; return ind; } public static int sumOfExamGrades() { int sum = 0; for (int i = 0; i < numberOfGrades; i++) { sum += examGrades[i]; } return sum; } public static double averageExamGrade() { return (sumOfExamGrades() * 1d) / (numberOfGrades * 1d); } public static int maxExamGrade() { int max = -1; for (int i = 0; i < numberOfGrades; i++) { max = Math.max(max, examGrades[i]); } return max; } public static int indexOfFirstMaxExamGrade() { int max = examGrades[0]; int ind = 0; for (int i = 1; i < numberOfGrades; i++) { if (examGrades[i] > max) { max = examGrades[i]; ind = i; } } return ind; } public static int minExamGrade() { int min = Integer.MAX_VALUE; for (int i = 0; i < numberOfGrades; i++) { min = Math.min(min, examGrades[i]); } return min; } public static int indexOfFirstMinExamGrade(){ int min = examGrades[0]; int ind = 0; for(int i=1;i<numberOfGrades;i++){ if(examGrades[i]<min){ min = examGrades[i]; ind = i; } } return ind; } public static int numberOfBelowAverageGrades(){ int ans = 0; double avg = averageExamGrade(); for(int i=0;i<numberOfGrades;i++){ if(examGrades[i]<avg){ ans++; } } return ans; } public static int numberOfAboveAverageGrades() { int ans = 0; double avg = averageExamGrade(); for(int i=0;i<numberOfGrades;i++){ if(examGrades[i]>avg){ ans++; } } return ans; } public static void main (String[] args) { readExamGrades(); System.out.println("Number Of Grades = "+numberOfGrades); System.out.println("Maximum Exam Grade = "+maxExamGrade()+" At Index = "+indexOfFirstMaxExamGrade()); System.out.println("Minimum Exam Grade = "+minExamGrade()+" At Index = "+indexOfFirstMinExamGrade()); System.out.println("Number Of Below Average Exam Grades = "+numberOfBelowAverageGrades()); System.out.println("Number Of Above Average Exam Grades = "+numberOfAboveAverageGrades()); System.out.println(""); } }

When I enter with MY program Only this shows I know that I need the entire expected output to show for that input and the other. Please if you don't understand don't try answering. Either fix or make new one. So far in this course, all ofyour programs have been written to be fully contained inside a single method named main. The main method is where Java begins execution of your program. In this assignment, you will coding other methods in addition to the main method. These additional methods will perform specific funtions and, in most cases, return results. This assignment is similar, but not identical, to the GradesArray assignment that you did in Homework 5-1. Your class should be named ExamGrades. You should have the following global definitions: public static final int MAX ExAM GRADES 100; public static intU examGrades new int [MAX EXAM GRADES) public static int numberofGrades; Your program will have the following methods: 1. public static int readExamGrades This method will read a list of exam grades from the user and place them into the examGrades array. The exam grades are all int values, and there will be a negative number used as a sentinel value to indicate the end of the input. (Please note that this negative number is used only to end the reading of the exam grades and it should not be used in any of your calculation. Your prompt to the user to enter a grade should be: Enter a grade Parameters This method has no parameters as indicated by the fact that there is nothing inside the in the method definition. Return value This method returns the number of grades that were read from the user. Side Effects n addition to changing the contents of the examGrades amay, this method will set the global variable numberofGrades to the actual number of grades obtained from the user. 2. public static int sumofExamGrades This method will compute the sum of all the grades in the examGrades array. Parameters This method has no parameters, as indicated by the fact that there is nothing inside the in the method definition. Return value This method returns the computed sum of all the grades. Side Effects None.

Explanation / Answer

In Your Code, Main method is running only once, even though there are inputs after -1.

So consider like this in case there is input line starting with -1 means that is end of the input lines. This Means the Number of Grades for that input will be Zero.

Newly added Code made as bold to understand what is newly added.

Updated Program:

import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class ExamGrades {
public static final int MAX_EXAM_GRADES = 100;
public static int[] examGrades = new int[MAX_EXAM_GRADES];
public static int numberOfGrades;
public static int readExamGrades() {
System.out.println("Enter a grade : ");
Scanner obj = new Scanner(System.in);
int x;
int ind = 0;

while ((x = obj.nextInt()) >= 0) {
System.out.println("Enter a grade : ");
examGrades[ind++] = x;
}
numberOfGrades = ind;
return ind;
}
public static int sumOfExamGrades() {
int sum = 0;
for (int i = 0; i < numberOfGrades; i++) {
sum += examGrades[i];
}
return sum;
}
public static double averageExamGrade() {
return (sumOfExamGrades() * 1d) / (numberOfGrades * 1d);
}
public static int maxExamGrade() {
int max = -1;
for (int i = 0; i < numberOfGrades; i++) {
max = Math.max(max, examGrades[i]);
}
return max;
}
public static int indexOfFirstMaxExamGrade() {
int max = examGrades[0];
int ind = 0;
for (int i = 1; i < numberOfGrades; i++) {
if (examGrades[i] > max) {
   max = examGrades[i];
   ind = i;
}
}
return ind;
}
public static int minExamGrade() {
int min = Integer.MAX_VALUE;
for (int i = 0; i < numberOfGrades; i++) {
min = Math.min(min, examGrades[i]);
}
return min;
}
public static int indexOfFirstMinExamGrade(){
int min = examGrades[0];
int ind = 0;
for(int i=1;i<numberOfGrades;i++){
if(examGrades[i]<min){
min = examGrades[i];
ind = i;
}
}
return ind;
}
public static int numberOfBelowAverageGrades(){
int ans = 0;
double avg = averageExamGrade();
for(int i=0;i<numberOfGrades;i++){
if(examGrades[i]<avg){
ans++;
}
}
return ans;
}
public static int numberOfAboveAverageGrades()
{
int ans = 0;
double avg = averageExamGrade();
for(int i=0;i<numberOfGrades;i++){
if(examGrades[i]>avg){
ans++;
}
}
return ans;
}
public static void main (String[] args) {
   while(true) { // This loop run indefintely
        readExamGrades();
        if(numberOfGrades==0) { // Stop reading In case there are zero inputs from the input line
            break;

      }
        System.out.println("Number Of Grades = "+numberOfGrades);
        System.out.println("Maximum Exam Grade = "+maxExamGrade()+" At Index = "+indexOfFirstMaxExamGrade());
        System.out.println("Minimum Exam Grade = "+minExamGrade()+" At Index = "+indexOfFirstMinExamGrade());
        System.out.println("Number Of Below Average Exam Grades = "+numberOfBelowAverageGrades());
        System.out.println("Number Of Above Average Exam Grades = "+numberOfAboveAverageGrades());
        System.out.println("");
    }
}
}

Sample Input:

25 75 -1

0 10 20 30 40 50 60 70 80 90 100 -1

-1

Sample output:

Enter Grade:

Enter Grade:

Enter Grade:

Number of Grades = 2

Maximum Exam Grade = 75 At Index = 1

Minimun Exam Grade = 25 At Index = 0

Number of Below Average Exam Grades = 1

Number of Above Average Exam Grades = 1

Enter Grade:

Enter Grade:

Enter Grade:

Enter Grade:

Enter Grade:

Enter Grade:

Enter Grade:

Enter Grade:

Enter Grade:

Enter Grade:

Enter Grade:

Enter Grade:

Number of Grades = 11

Maximum Exam Grade = 100 At Index = 10

Minimun Exam Grade = 0 At Index = 0

Number of Below Average Exam Grades = 5

Number of Above Average Exam Grades = 5

Enter Grade: