您好,我是编码的初学者,我刚试过第一个项目。它是高尔夫的标准划痕分数。每当我运行代码时,它就会以完全错误的分数出现。这是代码:
import java.util.Scanner;
public class StandardScratch {
public static void main(String[] args) {
double Par1 = 0.0,
Par2 = 0.0,
Par3 = 0.0,
difficulty = 0.0;
String operation;
Scanner scannerObject = new Scanner(System.in);
System.out.println("How many par 3 holes are there?");
Par1 = scannerObject. nextDouble();
System.out.println("How many par 4 holes are there?");
Par2 = scannerObject. nextDouble();
System.out.println("How many par 5 holes are there?");
Par3 = scannerObject. nextDouble();
System.out.println("What is the difficulty adjustment for the course?");
difficulty = scannerObject. nextDouble();
System.out.println("The Standard Scratch for the course is:" + ((Par1 * 6) + (Par2 * 4) + (Par3 * 5) - difficulty));
}
}
当我尝试运行数字为6,10,2和-2的代码时,它的结果为88,而真正的分数应为66.谢谢!
答案 0 :(得分:1)
你编码了这个:
height = 8
ax.barh(yvalues-width/2, xvalues, height=height, color='blue', align='center')
ax.barh(yvalues+width/2, xvalues, height=height, color='red', align='center')
高尔夫球中3杆洞的划痕得分实际为3。
对变量使用误导性名称没有任何帮助。