ユーザー入力の「sides」変数に基づいてステートメントを複数回出力する for ループを作成するのに助けが必要です。while ループにも問題があるようです。構文が間違っている場合はお知らせください。
import java.util.Scanner;
public class Lab6 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int sides = 0;
String poly = "ERROR!!!!!!";
System.out.print("Enter a number from 3 to 12: ");
sides = scan.nextInt();
while (sides > 3 || < 12 ){
System.out.println("Please enter a number from 3 to 12: ")
}
if(sides == 3) {
poly = "Triangle";
} else if(sides == 4) {
poly = "Quadrilaterl";
} else if(sides == 5) {
poly = "Pentagon";
} else if(sides == 6) {
poly = "Hexagon";
} else if(sides == 7) {
poly = "Heptagon";
} else if(sides == 8) {
poly = "Octagon";
} else if(sides == 9) {
poly = "Nonagon";
} else if(sides == 10) {
poly = "Decagon";
} else if(sides == 12) {
poly = "Dodecagon";
}
for (sides >= 3 || <= 12){
System.out.printf("\nA polygon with %d sides is called a(n) %s.", sides, poly);//TODO:Use a 'for loop' here!
}
}