[英]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.