我尝试了我知道的每一个导入,它基本上仍然在使用键盘或数学的每一行上给我类、接口或枚举预期错误。
如果您想知道程序做了什么,假设找到用户输入的 2 个点之间的距离。
// Sam
// 9.25.13
// import csl.Keyboard from the L: drive jdk
import java.io.*;
import java.util.*;
public class swagggg
public static void main ( String [] args)
{
// declare variables
int x1, y1 ,x2, y2;
double distance;
// get user input
Scanner Keyboard = new Scanner (System.in);
System.out.println("Enter the first set of coordinates: ");
x1 = Keyboard.nextInt();
y1 = Keyboard.nextInt();
System.out.println("Enter the second set of coordinates: ");
x2 = Keyboard.nextInt();
y2 = Keyboard.nextInt();
// calculate using the Math class static method
distance = Math.sqrt(Math.pow(x2-x1,2) + (Math.pow(y2-y1,2));
// out results
System.out.println ("The distance between (" +x1+","+y1+") and ("+ x2 +","+y2+") is " + distance);
}
}
/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~第一个坐标,看起来像这样
Enter the first set of coordinates:
(2,9)
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextInt(Scanner.java:2160)
at java.util.Scanner.nextInt(Scanner.java:2119)
at C2p8.main(C2p8.java:17)
Process completed.