오류가 발생합니다. sun.misc.FloatingDecimal에서 빈 문자열 : 나는 스레드에서 예외 오류 얻을스레드 "main"의 예외 java.lang.NumberFormatException : empty String FloatingDecimal & parseDouble
//이있다 "기본"java.lang.NumberFormatException의 : 나는 코드를 컴파일 할 때 어떤 이유로 오류가 나타나지 않습니다 .readJavaFormatString (FloatingDecimal.java:1842) at sun.misc.FloatingDecimal.parseDouble (FloatingDecimal.java:110) at java.lang.Double.parseDouble (Double.java:538) at Project3A.main (Project3A.java) : 42)
//Code starts here
import java.util.scanner;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
import java.util.Locate;
import java.text.NumberFormat;
public class Project3A
{
public static void main(String[] args)
{
int numloaves = 0;
int nummilk = 0;
double lbscheese = 0.00;
double brdperloaf = 1.50;
double milkperqrt = 1.00;
double chseperlbs = 0.50;
NumberFormat moneyFormat = NumberFormat.getCurrencyInstance(Locale.US);
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of loaves of bread: ");
int numloaves = sc.nextInt();
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of quarts of milk: ");
int nummilk = sc.nextInt();
Scanner sc = new Scanner(System.in);
System.ot.println("Enter the number of pounds of cheese: ");
int chseperlbs = sc.nextInt();
double brdcst = (numloaves * brdperloaves);
double mlkcst = (nummilk * milkperqrt);
double chsecst = (lbscheese * chseperlbs);
double ttlcost = (brdcst + mlkcst + chsecst);
String inputStr = JOptionPane.showInputDialog(null, "Enter number of apples");
double value = Double.parseDouble(" ");
System.out.println("Cost of Bread: " + brdcst);
System.out.println("Cost of Milk: " + mlkcst);
System.out.println("Cost of Cheese: " + chsecst);
double d = 1.234567;
DecimalFormat df = new DecimalFormat("#.##");
JOptionPane.showMessageDialog(null, "Total Cost of bread, milk and cheese is " + df.format(d));
System.out.println(df.format(d));
}
}
귀하의 질문에 오류가 있음에도 불구하고 오류 또는보고있는 곳을 저희에게 알려주지 않습니다. 이 질문을 개선하십시오. –