作业是提示输入圆的半径,计算面积,然后用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);
关于java - printf 模板的格式错误字符串问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48412512/