3

私が書いたスクリプトを修正しようとしています:

import java.util.Scanner;
public class Line2
{
    public static void main (String [] args)

    {
        Scanner scan = new Scanner (System.in);
        System.out.println ("Please enter 4 integers");
        int x1 = scan.nextInt();
        int y1 = scan.nextInt();
        int x2 = scan.nextInt ();
        int y2 = scan.nextInt ();
        double distance;

        //Asking the user to insert coordinates of both points and setting double
        // on distance in order to properly calculate the square root

        distance = Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
        System.out.print( "the length of the line between the points" (int x1, int x2) "and" (int y1, int y2) "is" distance);

       //Telling the program to calculate the distance of two points given by user
    }//end of method main

}

私は作成して内部に表示しようとしてx1 x2 y1y2ますが、許可されていません-Y(一種の)が期待されます...それが何であっても表示するにはどうすればよいintですか?(それ以外は、プログラムはかなりうまく動作すると思います..)ありがとう

4

4 に答える 4