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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!