Question: Hi friends, I'm writing this code in java and I can't figure out how I can fix this and complete the lab. Could someone help,

Hi friends, I'm writing this code in java and I can't figure out how I can fix this and complete the lab. Could someone help, please?

2. Assume you will have three grades. Create a double array of size 3. Reopen the file above and read in each number into the double array. Now create a method called addFive. The method will accept a double array, add five into each value in the double array, and then return it. You will also create another method called average. The method will take an array of doubles and give you the average of the numbers (so will return a double). Send the bumped up grades into the average method from main, and then back in main print out the average of the numbers. (should be 93.33). (the main method is given below).

import java.util.Scanner;

import java.io.File;

import java.io.IOException;

public class ReGrade {

public static double average(double[] grades2){

return ;

}

public static double[] addFive(double[] grades2){

return grades2;

}

public static void main(String[] args) throws IOException {

double[] grades = new double[3];

File myFile = new File("/Users/mcclainreggish/Documents/workspace/AverageGrades/src/myGrades.txt");

Scanner inputFile = new Scanner(myFile);

//write code to read and print each number from the file

double myGrade;

//counter

int x = 0;

while (inputFile.hasNext()){

myGrade = inputFile.nextDouble();

//put myGrade into the correct spot in the grades array

grades [x] = myGrade;

x++;

System.out.println(myGrade);

}

grades = addFive(grades);

double avg = 0;

avg = average(grades);

System.out.print("The average of the grades is" + avg);

inputFile.close();

}

}

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!