import java.util.*; public class CalcFac2 { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int counter; int n; int factorial; boolean isNegative; System.out.print("This program asks the user for a positive integer number, \n" + "computes the factorial value, and displays the answer.\n" + "Please enter a positive number: "); System.out.flush(); n = console.nextInt(); System.out.println(); factorial = n; if (n < 0) { System.out.println("Negative number found in data."); isNegative = true; } for (counter = 1; counter <= n; counter--) factorial = factorial * counter; System.out.println("The factorial of " + n + " is " + factorial); } }

I'm supposed to be able to enter any integer and have it calculate the correct factorial as well as tell the user if they accidentally entered a negative number. I'm having trouble finding in my book how you end an if statement if it becomes true. So that it doesn't go on with my for loop. I've hit a wall here, I've been sitting here for quite some time now trying to figure out where I went wrong with this because I know I don't have it calculating the factorial correctly. Any guidance would be greatly appreciated!