[Solved]Java Program 1 Write Class Reads Group Test Scores Positive Integers 1 100 Keyboard Main M Q37283478
Java Program
1. Write a class that reads in a group of test scores (positiveintegers from 1 to 100) from the keyboard. The main method of theclass calls a few other methods to calculate the average of all thescores as well as the highest and lowest score. The number ofscores is undetermined but there will be no more than 50. Anegative value is used to end the input loop.
import java.util.Scanner;
public class GradeStat
{
final static int MAXGRADES = 50; // maximum # of grades
public static void main (String[] args) {
int[] gradeArray = new int[MAXGRADES];
int pos = 0; // Index to the array
double avgOfGrades; // contains the average of grades
int highestGrade; // contains the highest grade
int lowestGrade; // contains the lowest grade
int sizeOfArray; // the size of the used array
// input grades Scanner scan = new Scanner ( System.in );
System.out.println(“Please input a grade from 1 to 100, a negativenumber to exit”);
gradeArray[pos] = scan.nextInt();
while (gradeArray[pos] >=1) {
pos++; // increment subscript
System.out.println(“Please input a grade from 1 to 100”);
gradeArray[pos] = scan.nextInt();
}
sizeOfArray = pos + 1; // The actual number of elements used inthe array
// call the Average method to calculate the average ofgradeArray
avgOfGrades = ________________________________________;
System.out.println(“The average of all the grades is “+avgOfGrades);
// call the Highest method to calculate the highest score ofgradeArray
highestGrade = ________________________________________;
System.out.println(“The highest grade is ” + highestGrade);
// call the Lowest method to calculate the lowest score ofgradeArray
lowestGrade = _________________________________________;
System.out.println(“The lowest grade is ” + lowestGrade);
}
// Fill in the code to determine average grade
public static double Average(int [] array, int size)
{
}
// Fill in the code to determine highest grade
public static int Highest (int [] array, int size)
{
}
// Fill in the code to determine lowest grade
public static int Lowest (int [] array, int size)
{
}
}
2. Complete the following program that defines class Square. Ithas one data field called side which keeps the length of the sideof a square. The class has the following methods: 1) setSide(doublesi), a void method that receives “si” as a parameter and sets thisvalue to side; 2) getArea(), a method that returns the area of asquare. 3) a default constructor method that sets data member sideto 0; 3) a constructor that takes the “si” as a parameter and setsthis value to data member side.
import java.util.Scanner;
public class Square
{
//define the data member here
// implement all the methods here
public static void main(String[] args)
{
double s;
// create a keyboard object Scannerkbd=________________________________;
System.println(“Please input the side of a square”);
// read in the value for rad from keyboard
s =_______________________________________;
// create an object of Square using the default constructor
Square aSquare = _______________________;
// create an object of Square with 2 as its side value
Square bSquare = _______________________;
__________________________________; // display areae ofaSquare
__________________________________; // Sets the side of aSquare tothe value of s
__________________________________; // display areae of aSquare
}
}
Expert Answer
Answer to Java Program 1. Write a class that reads in a group of test scores (positive integers from 1 to 100) from the keyboard. … . . .
OR

