1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

File/Method/Array grade calculations

Discussion in 'Java' started by Tigers27, Sep 20, 2013.

  1. Tigers27

    Tigers27 New Member

    I'm trying to write this Java program that reads student names and their scores from a file. I have to create 2 methods inside of main that calculate the average grade and determines the appropriate letter value and output that to a separate file. So far I have it able to do the calculations, however I am having problems with the methods (where they go, how to define/call, etc) Obviously, methods have given me a lot of trouble before and are doing it again. I really need help because this assignment is due soon and I have no clue what to do :(

    import java.io.*;
    import java.util.*;
    public class Lab2_1 {
      public static void main (String[]args)
        throws FileNotFoundException {
        Scanner input = new Scanner(new File("Ch7_Ex14Data.txt")); // reading from file
    public static double averageMethod(double test1 + test2 + test3 + test4 + test5){}
    public static String letterMethod(double calculateAverage) {
          if (calculateAverage >= 100){
          }else if(calculateAverage >= 89){
          }else if (calculateAverage >= 79){
          }else if (calculateAverage >= 69){
        double test1, test2, test3, test4, test5;
        String firstName;
        double calculateAverage;
        while (input.hasNext())
          firstName = input.next();
          System.out.print(firstName + "\t");
          test1 = input.nextDouble();
          test2 = input.nextDouble();
          test3 = input.nextDouble();
          test4 = input.nextDouble();
          test5 = input.nextDouble();
          System.out.print((test1 + test2 + test3 + test4 + test5)/5);
         double average= averageMethod(test1 + test2 + test3 + test4 + test5)/5.0;
         double letter = letterMethod(return calculateAverage);

Share This Page