我花了一段时间试图找出为什么它不会在我的java代码中使用十进制格式。我已经用其他整数声明了小数格式,但仍然出现错误。这里是我的代码:Java帮助十进制格式无法解析为一种类型
public class Assign31
{
public static void main(String [] args)
{
DecimalFormat speedPattern = new DecimalFormat("00.00");
int gearRadius = 100;
double pi = Math.PI;
int cadence = 90;
double gearspeed = gearRadius * pi;
double speedmph = gearspeed % cadence;
System.out.println("The speed of the cyclist on a bike with gear 100.0 and cadence 90 is " +
speedmph + " mph.");
System.out.println("The speed (rounded) of the cycleist on the bike with gear 100.0 and cadence 90 is " +
speedPattern.format(speedmph));
}
}
发表您的错误取悦 – 75inchpianist