我想知道为什么我的程序不能在Java博士上正确编译。我的代码有问题吗?
练习测试#1
import java.util.Scanner;
public class practest1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in); //reads keyboard input
System.out.println("please input a string, float or integer"); //asks the user to input into the text field.
String twine; //names string with variable name of "twine".
float wood; //names float with variable name of "wood".
int maths; //names int with the variable name of "maths".
System.out.println("Please type a string (please input words"); //asks the user to input a sting.
twine = sc.nextLine(); // links twine to the entered input
System.out.println("Thanks for entering a string" + twine); //displays twine on the screen to siqnify what the user entered
System.out.println("Please type a float (please input decimal point number"); //asks the user to input a decimal point number.
wood = sc.nextFloat(); // links wood to the entered input
System.out.println("Thanks for entering a float" + wood); //displays wood on the screen to siqnify what the user entered
System.out.println("Please type a int (please input a number"); //asks the user to input a number.
maths = sc.nextInt(); // links maths to the entered input
System.out.println("Thanks for entering some integer" + maths); //displays maths on the screen to siqnify what the user entered
}
}
答案 0 :(得分:1)
如评论所示,我认为它会编译。尝试确保您的文件名与类名相同!