我是第一个编程课;任何人都可以帮我理解为什么我不能打印我的最后一行了吗?
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 + ");
}
}
}
答案 0 :(得分:3)
您的最后一行语法非常混乱。
此
System.out.println("The triangles with sides " + a + ", "
+ " + b + ", and " + c + ", is + triangleType + ");
应该是
System.out.println("The triangles with sides " + a + ", "
+ b + ", and " + c + ", is " + triangleType);
答案 1 :(得分:2)
System.out.println("The triangles with sides " + a + ", "
+ " + b + ", and " + c + ", is + triangleType + ");
您使用的是什么IDE /编辑器?它应该在这里显示错误。这应该是
System.out.println("The triangles with sides " + a + ", "
+ b + ", and " + c + ", is" + triangleType);
这是更好的