我在我的第一個編程課上;任何人都可以幫助我理解爲什麼我不能打印我的最後一行嗎?打印一個字符串?
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
兩個查詢。第一個 - 爲什麼你認爲這位教授非常糟糕?第二個 - 爲什麼你認爲'只希望我們編碼,因爲他編碼不總是理想的'? –
一。他非常糟糕,因爲他試圖解釋編碼技術以及其中不清楚的編碼技術。然後他問道是否有意義,當你告訴他時,他並不清楚他指責你這樣說:「這很簡單,如果你不明白你不應該成爲計算機科學專業。」我覺得這很糟糕,因爲這是我的第一個計算機科學課。我也相信編碼可以用不同的創新方式完成。他明確告訴我們不要按照他告訴我們的方式以任何其他方式執行我們的代碼。我認爲或相信我們應該探索其他編碼選項 –