-
Notifications
You must be signed in to change notification settings - Fork 9
Home
pooopy edited this page Nov 1, 2015
·
1 revision
package coordinatesystem;
import javax.swing.JOptionPane;
public class CoordinateSystem {
private static double x;
private static double y;
public static void move() {
double step = 0.0;
String input1 = JOptionPane.showInputDialog("Enter number for X:");
if (input1 != null) {
x = Double.parseDouble(input1);
} else {
input1 = JOptionPane.showInputDialog(null, "Enter valid number for x:");
}
String input = JOptionPane.showInputDialog("Enter number for Y:");
if (input != null) {
y = Double.parseDouble(input);
} else {
input = JOptionPane.showInputDialog(null, "Enter valid number for y:");
}
String input2 = JOptionPane.showInputDialog("Enter number for the step:");
if (input2 != null) {
step = Double.parseDouble(input2);
} else {
input = JOptionPane.showInputDialog(null, "Enter valid number for step:");
}
x = ((x + step - step + 3 * step) * (-1) + step - step + step - step) * (-1) + step - step + step - step;
y = ((y - step - step + step) * (-1) * (-1));
JOptionPane.showMessageDialog(null, "Entered numbers: \n" + "X: " + input1 + "; Y: " + input + "; Step: " + input2 + "\nX = " + x + "Y= " + y);
}
public static void main(String[] args) {
move();
}
}