简体   繁体   English

使用Eclipse进行Java获取无法解决扫描程序。 有人知道我做错了吗?

[英]Using Eclipse for java getting cannot be resolved for scanner. Anyone know what I have done wrong?

Secondary question is im notcing that not all of my code is changing colors to signify itself. 第二个问题是,并不是我的所有代码都在改变颜色来表示自己。 IN this screenshot https://puu.sh/xCe5B/b2ef5f8948.png 在此屏幕截图中https://puu.sh/xCe5B/b2ef5f8948.png

You will see race14 is not turning cyan like the rest. 您会看到race14没有像其他地方一样变成青绿色。 Also the Math.min function is not working changing colors. 此外,Math.min函数无法更改颜色。

My 3rd question is, Is the way I am doing Math.min right? 我的第三个问题是,我做Math.min的方式正确吗?

//input scanner
import java.util.Scanner;

public class Edmonds_Jonny_hw4p1.java {

public static void main(String[] args) {
    // TODO Auto-generated method stub
//scanner input
    Scanner input = new Scanner(System.in);

    //prompt user to enter in race details
    System.out.print("Enter the time for each runner for race 1, once"
    + "line");
    int race11 = input.nextInt();
    int race12 = input.nextInt();
    int race13 = input.nextInt();
    int race14 = input.nextInt();

    int fastest1 = Math.min(race11, race12, Math.min(race13, race14));
    //output fastest vs slowest for race 1
    System.out.print("Race1: Fastest: " +

}

Your problem might just be eclipse bugging. 您的问题可能只是日食漏洞。 Whatever... 随你...

Your code looks good so far. 到目前为止,您的代码看起来不错。 You're missing some brackets in the end. 最后,您缺少一些括号。 I completed your code and it works for me: 我完成了您的代码,它对我有用:

import java.util.Scanner;
public class Racers {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println("..."); //edit
        int race11 = input.nextInt();
        int race12 = input.nextInt();
        int race13 = input.nextInt();
        int race14 = input.nextInt();

        int fastest1 = Math.min(Math.min(race11, race12), Math.min(race13, race14));
        System.out.println("fastest time: " + fastest1);
    }
}

Also have a look here for Math.min: https://www.tutorialspoint.com/java/lang/math_min_int.htm 也可以在此处查看Math.min: https ://www.tutorialspoint.com/java/lang/math_min_int.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Scanner 的 java.io.FileNotFoundException(未找到文件)。 我的代码有什么问题? - java.io.FileNotFoundException (File not found) using Scanner. What's wrong in my code? 我不断收到“扫描仪无法解析为类型”错误。 我正在使用 Java 和 Visual Studio,这是针对初学者的 Java 课程 - I keep getting an "Scanner cannot be resolved to a type" error. I am using Java and Visual Studio and this is for a beginner Java class 有人知道我在执行这个 java 代码时做错了什么吗? - Anyone know what I am doing wrong to execute this java code? “无法解决” Java扫描仪 - 'in cannot be resolved' Java Scanner 使用扫描仪分析文件中的输入。 JAVA - Parsing input from a file using Scanner. JAVA 使用扫描仪将单词的出现次数及其计数存储在文件中。(Java) - Store occurences of words in a file and their count,using Scanner.( Java ) 我做错了什么? 静态错误[Java] - What have I done wrong? Static Errors [Java] 我在 Android 代码中做错了什么? - What have I done wrong in the Android code? 带有扫描仪的 Java 应用程序出错。 Next() 与 NextLine() 以及为什么我收到错误? - Error in Java app with scanner. Next() vs NextLine() and why Im getting an error? 使用扫描仪时逻辑错误。 文本文件的第一行未打印到标准输出 - Wrong logic in using scanner. The first line of the text file is not printed out to stdout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM