我在我的第一个编程课上;任何人都可以帮助我理解为什么我不能打印我的最后一行吗?打印一个字符串?
package program4;
import java.util.*;
public class Program4 {
public static void main(String[] args) {
int a, b, c, numComparisons;
String comparisons = "Comparisons for triangleType determination: ";
Scanner scan = new Scanner(System.in);
for (int i = 0; i < 7; i++) {
}
String triangleType = "";
System.out.print("Enter 3 positive integer lengths for the sides of a "
+ "triangle:");
a = scan.nextInt();
b = scan.nextInt();
c = scan.nextInt();
System.out.println("The input lengths are: a = " + a + ", b = " + b + ", and"
+ " c = " + c + "");
if ((a + b < c) || (b + c < a) || (a + c < b)) {
System.out.print("There is no triangle with sides " + a + ", " + b + " and "
+ "" + c + ".");
} else {
numComparisons = 1;
comparisons += "a==b";
if (a == b) {
comparisons += "(T)" + "(b==c)";
numComparisons++;
if (b == c) {
comparisons += "(T)";
triangleType = "Equilateral";
}
} else {
comparisons += "(F)";
if (a == c) {
comparisons += "(T)";
triangleType = "Isosceles";
} else {
comparisons += "b==c";
numComparisons++;
comparisons += "(F)";
if (b == c) {
triangleType = "Isosceles";
} else {
comparisons += "a==c";
numComparisons++;
comparisons += "(F)";
triangleType = "Scalene";
}
}
}
System.out.printf("" + comparisons + (""));
System.out.printf("numComparisons = " + numComparisons);
System.out.println("The triangles with sides " + a + ", "
+ " + b + ", and " + c + ", is + triangleType + ");
}
}
}
搜寻失踪在你的上线“+” – DZDomi
两个查询。第一个 - 为什么你认为这位教授非常糟糕?第二个 - 为什么你认为'只希望我们编码,因为他编码不总是理想的'? –
一。他非常糟糕,因为他试图解释编码技术以及其中不清楚的编码技术。然后他问道是否有意义,当你告诉他时,他并不清楚他指责你这样说:“这很简单,如果你不明白你不应该成为计算机科学专业。”我觉得这很糟糕,因为这是我的第一个计算机科学课。我也相信编码可以用不同的创新方式完成。他明确告诉我们不要按照他告诉我们的方式以任何其他方式执行我们的代码。我认为或相信我们应该探索其他编码选项 –