gpt4 book ai didi

java - Java博士;为什么不编译呢?

转载 作者:行者123 更新时间:2023-12-02 11:12:44 24 4
gpt4 key购买 nike

我想知道为什么我的程序无法在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

}
}

最佳答案

如注释中所示,我认为它可以编译。尝试确保您的文件名与类名相同!

关于java - Java博士;为什么不编译呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29463211/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com