내 코드를 수정하는 데 어려움이 있습니다. I 나타나는 오류 메시지는 다음 스레드에 "메인"에 java.lang.NumberFormatException의Error : java.lang.NumberFormatException
예외 : 입력 문자열 : sun.misc.FloatingDecimal.readJavaFormatString (알 소스) 에서 "60 45 100 30 20"에서 자바 내가 제대로 문자열로 내 더블 변수를 분석 한 생각
import java.io.*;
import java.math.*;
public class Lab3
{
public static void main(String[] args) throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
double pVelocity, pAngle, tDistance, tSize, tElevation;
double radians, time, height, pDistance;
String input = br.readLine();
String[] values = input.split("\\+");
pVelocity = Double.parseDouble(values[0]);
pAngle = Double.parseDouble(values[1]);
tDistance = Double.parseDouble(values[2]);
tSize = Double.parseDouble(values[3]);
tElevation = Double.parseDouble(values[4]);
while(pVelocity != 0 && pAngle != 0 && tDistance != 0 && tSize != 0 && tElevation != 0)
{
radians = pAngle*(Math.PI/180);
time = tDistance/(pVelocity*Math.cos(radians));
height = (pVelocity*time*Math.sin(radians))-(32.17*time*time)/2;
pDistance = time*(pVelocity*Math.cos(radians));
if(pVelocity*Math.cos(radians) == 0)
System.out.print("The computed distance cannot be calculated with the given data.");
else if(height > tElevation && height <= tSize)
System.out.print("The target was hit by the projectile.");
else if(height < tElevation)
System.out.print("The projectile was too low.");
else if(height > tSize)
System.out.print("The projectile was too high.");
else if(pDistance < tDistance)
System.out.print("The computed distance was too short to reach the target.");
else if(height < 0)
System.out.println("The projectile's velocity is " + pVelocity + "feet per second.");
System.out.println("The angle of elevation is " + radians +"degrees.");
System.out.println("The distance to the target is " + tDistance + "feet.");
System.out.println("The target's size is " + tSize + "feet.");
System.out.println("The target is located " + tElevation + "feet above the ground.");
}
}
}
: Lab3.main에서 .lang.Double.parseDouble (알 수없는 소스) (Lab3.java:15는) 다음
내 코드입니다 변수를 포함하며, Eclipse는 컴파일시 오류를 표시하지 않습니다. 누구든지이 문제에 대한 해결책을 제시 할 수 있습니까?
도움 주셔서 감사합니다. 이것은 그것을 해결! – dabad