First you need to change
while (sides > 3 || < 12 ){
System.out.println("Please enter a number from 3 to 12: ")
}
to
while (sides < 3 || sides > 12) {
System.out.println("Please enter a number from 3 to 12: ");
sides = scan.nextInt();
}
Then change this
for (sides >= 3 || <= 12){
System.out.printf("\nA polygon with %d sides is called a(n) %s.", sides, poly);
to
for (int i = 0; i < sides; i++)
System.out.printf("\nA polygon with %d sides is called a(n) %s.", sides, poly);
That will print the statement, the number of times there are sides.
Output:
Enter a number from 3 to 12: 1
Please enter a number from 3 to 12: 2
Please enter a number from 3 to 12: 3
A polygon with 3 sides is called a(n) Triangle.
A polygon with 3 sides is called a(n) Triangle.
A polygon with 3 sides is called a(n) Triangle.
This looks like homework though… You don’t want to get caught asking for answers on here…
1
solved I need to to use a for loop to execute println() multiple times [closed]