Em ngồi này giờ mà suy nghĩ không ra cách nào để cho 2 cái biến x, y lưu vào hàm như hình sau ạ.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package btvnmonday;
import data.Point;
import java.util.Scanner;
import data.Line;
/**
*
* @author ASUS
*/
public class BtvnMonday {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
double x = 0, y = 0, x1 = 0, y1 = 0;
String tenToaDo;
Scanner sc = new Scanner(System.in);
System.out.println("Nhập tên tọa độ: ");
tenToaDo = sc.next();
checkErrorX(x);
checkErrorY(y);
Point A = new Point(x, y);
A.showAll();
System.out.println("");
System.out.println("Nhập tên tọa độ: ");
tenToaDo = sc.next();
sc.nextLine();
do {
System.out.println("Nhập tọa độ x: ");
try {
x1 = Double.parseDouble(sc.nextLine());
break;
} catch (Exception e) {
System.out.println("Bạn đã nhập sai .Yêu cầu bạn nhập 1 con số ");
}
} while (true);
do {
System.out.println("Nhập tọa độ y: ");
try {
y1 = Double.parseDouble(sc.nextLine());
break;
} catch (Exception e) {
System.out.println("Bạn đã nhập sai");
System.out.println("Yêu cầu nhập lại");
}
} while (true);
Point B = new Point(x1, y1);
System.out.println(B);
System.out.println("độ dài của " + A + "và " + B + "là :" + (Math.sqrt(((x1 - x) * (x1 - x)) + ((y1 - y) * (y1 - y)))));
}
public static void checkErrorX(double x) {
Scanner sc = new Scanner(System.in);
do {
System.out.println("Nhập tọa độ x: ");
try {
x = Double.parseDouble(sc.nextLine());
break;
} catch (Exception e) {
System.out.println("Bạn đã nhập sai .Yêu cầu bạn nhập 1 con số ");
}
} while (true);
}
public static void checkErrorY(double y) {
Scanner sc = new Scanner(System.in);
do {
System.out.println("Nhập tọa độ y: ");
try {
y = Double.parseDouble(sc.nextLine());
break;
} catch (Exception e) {
System.out.println("Bạn đã nhập sai .Yêu cầu bạn nhập 1 con số ");
}
} while (true);
}
}

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?