が非常にうまくコンパイルされますが、実行時にメソッドUserInputWindowsの文字列入力でエラーが発生します。私は問題のない前にこのようなwhileループを書いたが、私は今なぜエラーになっているのか理解できないようだ。プログラムはどこにもありませんでした。私はちょうど私が何かエラーがあるかどうかを確認するためにそれを本当に走った。ここではそれは、単純なタイプミスだプログラムは非常にうまくコンパイルされますが、ドロップを実行すると文字列入力でエラー
enter code here
import java.util.Scanner;
public class PaintEstimate
{
final static double WallAndCeilingPaintCost = 18.50;//cost for 1 gallon
//final static double WhiteEnamelPaintCost = 9.50; //cost for 1 quart//using only for refrence now//changed to _MoldingCostPerQuart
//final static double ColorEnamelPaintCost = 12.50; //cost for 1 quart//using only for refrence now// changed to _MoldingCostPerQuart
final static double CoverageOfWallAndCeilingPaint = 250.00; // coverage of wall and ceiling paint in sqft
final static double CoverageOfEnamelPaint = 100.00;// coverage of enamel paint both color and whit in linear sqft
public static double IntchesToFeet;
public static double RoomSquareFeet, CeilingSqaureFeet;
public static double InchRoomWidth, InchRoomLength, InchRoomHeight;
public static double FeetRoomWidth, FeetRoomLength, FeetRoomHeight;
public static double NumberOfWindows, NumberOfDoors;
public static double InchesWindowsHeight, InchesWindowsLength, InchesWindowsMoldingWidth;
public static double InchesDoorsHeight, InchesDoorsLength, InchesDoorsMoldingWidth;
public static String WindowsMoldingColorOrWhite, DoorsMoldingColorOrWhite;
public static double WindowsMoldingCostPerQuart = 0;
public static double DoorsMoldingCostPerQuart = 0;
public static Scanner scan = new Scanner(System.in);
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
UserInputWallsAndCeiling();
UserInputWindows();
UserInputDoors();
}
public static void UserInputWallsAndCeiling()
{
System.out.println("What is the room height in inches? ");
InchRoomHeight = scan.nextDouble();
System.out.println("What is the room width in inches? ");
InchRoomWidth = scan.nextDouble();
System.out.println("What is the room length in inches? ");
InchRoomWidth = scan.nextDouble();
}
public static void UserInputWindows()
{
System.out.println("How many windows are in the room? ");
NumberOfWindows = scan.nextDouble();
if(NumberOfWindows > 0)
{
System.out.println("What are the windows height in inches? ");
InchesWindowsHeight = scan.nextDouble();
System.out.println("What are the windows length in inches? ");
InchesWindowsLength = scan.nextDouble();
System.out.println("What are the windows molding width in inches? ");
InchesWindowsMoldingWidth = scan.nextDouble();
System.out.println("Is the windows molding color or white? ");
boolean WindowsTrue = false;
while (!WindowsTrue)
{
System.out.println("Is the doors molding color or white? ");
DoorsMoldingColorOrWhite = scan.nextLine();
if (WindowsMoldingColorOrWhite.equals("color"))
{
WindowsMoldingCostPerQuart = 12.50;
WindowsTrue = true;
}
else if (WindowsMoldingColorOrWhite.equals("white"))
{
WindowsMoldingCostPerQuart = 9.50;
WindowsTrue = true;
}
else
{
System.out.println("Please enter if the molding is color or white");
}
}
}
}
public static void UserInputDoors()
{
System.out.print("How many doors are in the room? ");
NumberOfDoors = scan.nextDouble();
if(NumberOfDoors > 0)
{
System.out.println("What are the doors height in inches? ");
InchesDoorsHeight = scan.nextDouble();
System.out.println("What are the doors length in inches? ");
InchesDoorsLength = scan.nextDouble();
System.out.println("What are the doors molding width in inches? ");
InchesDoorsMoldingWidth = scan.nextDouble();
boolean DoorsTrue = false;
while (!DoorsTrue)
{
System.out.println("Is the doors molding color or white? ");
DoorsMoldingColorOrWhite = scan.nextLine();
if (DoorsMoldingColorOrWhite.equals("color"))
{
DoorsMoldingCostPerQuart = 12.50;
DoorsTrue = true;
}
else if (DoorsMoldingColorOrWhite.equals("white"))
{
DoorsMoldingCostPerQuart = 9.50;
DoorsTrue = true;
}
else
{
System.out.println("Please enter if the molding is color or white");
}
}
//System.out.print(InchesDoorsHeight + " " + InchesDoorsLength + " " + DoorsMoldingColorOrWhite + " " + DoorsMoldingCostPerQuart)
}
}
public static void IntchesToFeet()
{
FeetRoomWidth= InchRoomWidth/12;
FeetRoomLength = InchRoomLength/12;
FeetRoomHeight = InchRoomHeight/12;
}
}
それは投げられるのですか? – CConard96
実際にメソッドと変数の命名法を改善する必要があります。 – SamTebbs33
私の変数はどんなに正確になりますか?彼らは文字通りコメントが必要なわけでもありません。なぜなら、その名前は彼らが何をするかを正確に伝えているからです。 –