import javax.swing.JOptionPane;
public class HW {
public static void main(String[] args)
{
String x1 = JOptionPane.showInputDialog(null, "X: ");
String y1 = JOptionPane.showInputDialog(null, "Y: ");
double x = Double.parseDouble(x1);
double y = Double.parseDouble(y1);
System.out.println("Sum: " + (x+y));
System.out.println("Difference: " + (x-y));
System.out.println("Product: " + (x*y));
System.out.println("Average: " + (x+y)/2);
System.out.println("Distance: " + Math.abs(x-y));
System.out.println("Maximum Value: " + Math.max(x,y));
System.out.println("Minimum Value: " + Math.min(x,y));
}
}
Basically, I'm trying to output the values to be like:
Sum: 5
Difference: 10
Product: 7
etc.
I've found how to do this with strings, but I'm unsure how to accomplish this with variables.