Alright, I am working with methods for the first time and need help, for some reason my program is not returning the right answer to tell if the number is prime or not, it is part of a larger code (thats why it starts out with an if statement)
Main:
if (inputi == 1){ //Grabs a number converts it than sends it to the method int exit = 0; do { String enter = JOptionPane.showInputDialog("Enter a number: "); int enteri = Integer.parseInt(enter); boolean kickback = isNotPrime(enteri); if (kickback = true){ output = enteri + " is not a prime number!"; } else { output = enteri + " is a prime number!"; exit = 1; } }while (exit > 1);
isNotPrime Method:
//Method for not prime numbers public static boolean isNotPrime(int number){ boolean prime = true; for (int i = 2; i < number; i++) { if (number % i == 0) { prime = false; break; } } return prime; }