I want to learn how to enter numbers from the keyboard. For example, let it be necessary to enter the coordinates of two points. The program, the text of which is below, makes it an awkward way. Here's what I don't like:
- After the program starts, the cursor in the console is not active. It is necessary to activate through the mouse.
- After entering the first pair of numbers and pressing the input, the line "Enter point2's x-, y-coordinates:" appears and the cursor is in front of the first character (ie, before 'E'), and not at the end of this line.
How to fix it, especially the 2nd moment? Or is it an Eclipse environment feature?
package dzmitrok; import javafx.geometry.*; import java.util.Scanner; public class TwoLineOnPlane { public static void main(String[] args) { Scanner myinput = new Scanner(System.in); System.out.print("Enter point1's x-, y-coordinates: "); double x1 = myinput.nextDouble(); double y1 = myinput.nextDouble(); System.out.print("Enter point2's x-, y-coordinates: "); double x2 = myinput.nextDouble(); double y2 = myinput.nextDouble(); Point2D p1 = new Point2D(x1, y1); Point2D p2 = new Point2D(x2, y2); System.out.println("Point1: " + p1.toString()); System.out.println("Point2: " + p2.toString()); } }