我有以下代码:
import java.util.Scanner;
import javax.swing.JOptionPane;
public class weatherCalc {
public static void main(String args[]) {
while (true) {
int division = 8125/1000;
Scanner in = new Scanner;
System.out.println("How far, in inches, is it moving on a 50-mile = 0.75 in? (Please use decimels)");
int weatherInput = in.nextInt();
System.out.println("How long is the time period in hours? (Please use decimels)");
int weatherTime = in.nextInt();
int weatherOutput = weatherInput/division*50/weatherTime;
System.out.println("The storm is travling at "+ weatherOutput +"MPH.");
}
}
}
您会在“ System.out.println(“中以50英里= 0.75英寸的距离(以英寸为单位)移动多少英寸(请使用分贝)”中的System)”);”在“ Scanner in = new Scanner;”的结尾加上红色下划线。我不知道为什么,只是想自己开发这个。我可能稍后再做一点工作。如果有人能告诉我原因,那将会有很大帮助。
最佳答案
Scanner in = new Scanner;
应该:
Scanner in = new Scanner(System.in);
关于java - System.out.println无法使用数字,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15820316/