0

Hey guys, I'm new here. I'm taking an intro programming course and I'm having problems getting this code to work. It needs to take two user input numbers and calculate figures based on them. The first part of the code compiles and works properly with a force induced test code. But the simulator won't work with actual user input numbers. Any thoughts? Thanks

```
public class Pair
{
public Pair(double aFirst, double aSecond)
{
P1 = aFirst;
P2 = aSecond;
}
private double aFirst;
private double aSecond;
private double P1;
private double P2;
private double Sum;
private double Difference;
private double Product;
private double Average;
private double Distance;
private double Maximum;
private double Minimum;
public double getSum()
{
Sum = (P1 + P2);
return Sum;
}
public double getDifference()
{
Difference = (P1 - P2);
return Difference;
}
public double getProduct()
{
Product = (P1 * P2);
return Product;
}
public double getAverage()
{
Average = (P1 + P2)/2;
return Average;
}
public double getDistance()
{
Distance = Math.abs(P1 - P2);
return Distance;
}
public double getMaximum()
{
Maximum = Math.max(P1, P2);
return Maximum;
}
public double getMinimum()
{
Minimum = Math.min(P1, P2);
return Minimum;
}
}
```

```
public class PairSimulator
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
Pair pair1 = new Pair(aFirst, aSecond) ;
String number1 = "Enter first number:";
double P1 = in.nextDouble();
String number2 = "Enter second number:";
double P2 = in.nextDouble();
System.out.println("The sum is: " + pair1.getSum());
System.out.println( "The difference is: " + pair1.getDifference());
System.out.println( "The product is: " + pair1.getProduct());
System.out.println( "The average is: " + pair1.getAverage());
System.out.println( "The distance is: " + pair1.getDistance());
System.out.println( "The maximum is: " + pair1.getMaximum());
System.out.println( "The minimum is: " + pair1.getMinimum());
}
}
```