Question
WILL LEAVE GOOD RATING. PLEASE HELP THANK YOU!! ( JAVA) Can you modify this program to a) a method readGrades that receives one int parameter
WILL LEAVE GOOD RATING. PLEASE HELP
THANK YOU!!
( JAVA) Can you modify this program to
- a) a method readGrades that receives one int parameter (how many grades to read), and returns an array of integers representing grades read in from the user.
- b) a method computeSum that receives an array of integers (grades) and an int (n), and computes and returns the sum of the first n integers in the array.
- c) a method computeAverage that receives an array of integers (grades) and an int (n), and computes and returns a double: the average of the first n integers in the array. Have your computeAverage method call your computeSum method.
- d) a method howManyCloseToAvg that receives 3 parameters: an array of integers (grades), a double (average), and an int (k), and computes and returns how many grades are within k of the average, e.g. if the array is {70, 80, 90, 100}, the average is 85, and k is 5, there are 2 grades within 5 of the average: 80 and 90. so the method should return 2.
- e) a method convertToLetterGrade that receives a double (average) and returns a char (the equivalent letter grade) as follows: Note: the range [x,y) means: between x and y, including x, excluding y. In Java, logical AND is &&, and logical OR is || (two consecutive vertical bars).
-
average letter grade [90,100] A [80,90) B [70,80) C [60,70) D [0,60) F
ORIGINAL PROGRAM
import java.util.Scanner; // Import the Scanner class
public class ComputationUpdate { public static void main (String[] args) { final int NUM_OF_GRADES = 3; int grade1, grade2, grade3; int sum; double average; // Create a Scanner object Scanner myObj = new Scanner(System.in); grade1 = myObj.nextInt(); grade2 = myObj.nextInt(); grade3 = myObj.nextInt(); sum = grade1 + grade2 + grade3; average = (double)sum / NUM_OF_GRADES; //Print the sum and average System.out.println("The sum is "+sum); System.out.println("The average is "+average); } }
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