格式错误的格式字符串问题与 printf 模板
Malformed format string issue with a printf template
作业是提示输入圆的半径,计算面积,然后用printf打印出来。经过大量挖掘后,我无法让错误消失。请告诉我我做错了什么。 printf模板下方出现黄色错误行:"Area of the Circle is (%f)^2*3.14=%f.." -- 这个模板是教授给的
System.out.print("Enter the radius of a circle: ");
float circleRadius = input.nextFloat();
float circleArea = 3.14F * circleRadius * circleRadius;
System.out.printf("Area of the Circle is (%f)^2*3.14=%f\n", circleArea);
您需要将每个格式说明符与一个参数相匹配
System.out.printf("Area of the Circle is (%f)^2*3.14=%f\n", circleRadius, circleArea);
作业是提示输入圆的半径,计算面积,然后用printf打印出来。经过大量挖掘后,我无法让错误消失。请告诉我我做错了什么。 printf模板下方出现黄色错误行:"Area of the Circle is (%f)^2*3.14=%f.." -- 这个模板是教授给的
System.out.print("Enter the radius of a circle: ");
float circleRadius = input.nextFloat();
float circleArea = 3.14F * circleRadius * circleRadius;
System.out.printf("Area of the Circle is (%f)^2*3.14=%f\n", circleArea);
您需要将每个格式说明符与一个参数相匹配
System.out.printf("Area of the Circle is (%f)^2*3.14=%f\n", circleRadius, circleArea);