-1
이 코드에서 두 개의 문자를 나눌 수 없습니다. 나는 cansNeeded의 가치를 찾을 필요하지만 오류2 개의 정수를 나눌 수 없습니다.
import java.util.Scanner;
import java.lang.Math; // Note: Needed for math functions
public class PaintEstimator {
public static void main(String[] args) {
//Create a new scanner
Scanner scnr = new Scanner(System.in);
//Set the values
double wallHeight = 0.0;
double wallWidth = 0.0;
double wallArea = 0.0;
double gallonsPaintNeeded = 0.0;
final double squareFeetPerGallons = 350.0;
final double gallonsPerCan = 1.0;
//Scan for user input
wallHeight = scnr.nextDouble();
wallHeight = scnr.nextDouble();
wallArea = (wallHeight * wallWidth);
gallonsPaintNeeded = (wallArea/squareFeetPerGallons);
//Print out the values
System.out.println("Enter wall height (feet): ");
System.out.println("Enter wall width (feet): ");
System.out.println("Wall area: square feet");
System.out.println("Paint needed: " + gallonsPaintNeeded + " gallons");
double cansNeeded = (gallonsPaintNeeded/gallonsPerCan);
System.out.println("Cans needed: " + cansNeeded + " can(s)");
return;
}
}
내가
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)
at PaintEstimator.main(PaintEstimator.java:21)
추가를 두 번이 "/"기호의 내 원래의 문제가 원인이 해결 듯이 오류가 계속 점점 계속 오류. 하지만 지금은 아래 오류가 있습니다. 어떤 도움이 필요합니까?
당신은 정수와 문자에 대해 이야기하고 있지만 실제로는 두배를 사용하고 있습니다. 질문을 더 명확하게 (올바른) 시도해 볼 수 있습니까? 이해하기 쉬울거야 – Stultuske
21 번 줄은 어느 쪽인가? –
입력 내용이 누락 된 것 같습니다. 무엇을 입력 했습니까? 또한 입력이 제공된 후에도 프롬프트가 인쇄됩니다. 아마도 뒤집혀 야합니다. – Thilo