Answered You can hire a professional tutor to get the answer.

QUESTION

Question: Having trouble with this code I wrote. It looks good to me and doesn't show any errors, however, I keep getting an error when I compile it....

Question:Having trouble with this code I wrote. It looks good to me and doesn't show any errors, however, I keep getting an error when I compile it. Can you see what I did wrong here? Also, here is the assignment with what a sample run should look like.

Question:

Here's my code with the error:

public class Average {

  public static void main(String[] args) {

    int n = Integer.parseInt(args[0]);

    String[] a = new String[n];

    int[] b = new int[n];

    int[] c = new int[n];

    int[] d = new int[n];

    double sum;

    double mean;

    int j = 0;

    String temp;

    int x, y, z;

    while (!StdIn.isEmpty()) {

      temp = StdIn.readString();

      x = StdIn.readInt();

      y = StdIn.readInt();

      z = StdIn.readInt();

      if (j < n) {

        a[j] = temp;

        b[j] = x;

        c[j] = y;

        d[j] = z;

        j++;

      }

    }

    for (int i = 0; i < n; i++) {

      sum = (b[i] + c[i] + d[i]);

      mean = sum / 3;

      System.out.printf(a[i] + " " + b[i] + " " + c[i] + " " + d[i] + " " + "%.2f", mean);

      System.out.println();

    }

  }

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question