Needing some help with a small problem. I have this program that is not compiling correctly. The instructions are simple which are: The PairTest should prompt the user for the two values, create a Pair object with the values and then print the average, distance, maximum, and minimum of the pair.
In theory, the output should look something like this:
Enter the first number:
5.5
Enter the second number:
3.0
Average: 4.25
Distance: 2.5
Maximum: 5.5
Minimum: 3.0
Here is what I have so far.
import java.lang.Math;
import java.util.Scanner;
public class PairTest
{
private static double num1;
private static double num2;
private static double average = (num1+num2)/2.0;
private static double distance = Math.abs(num1-num2);
private static double maximum = Math.max(num1, num2);
private static double minimum = Math.min(num1, num2);
private static Scanner in;
public static void main(String args[])
{
in = new Scanner(System.in);
System.out.println("Please enter a value for the first number: ");
num1 = in.nextDouble();
System.out.println("Please enter a value for the second number: ");
num2 = in.nextDouble();
System.out.println("Average: " + average);
System.out.println("Distance: " + distance);
System.out.println("Maximum Number: " + maximum);
System.out.println("Minimum Number: " + minimum);
}
}
}
Would someone be so kind to explain to me what I am doing wrong? I would greatly appreciate it.
The error that it is giving me is:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at PairTest.main(PairTest.java:15)
Thank you.