My program is a simple divisibility checker for some practice. I am trying to take a user input if the user wants to re-run the program. When I run the program, it takes the user input for the number but the input statement for exiting the program is just not working. Please see the code below for reference.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
while(true){
Scanner input = new Scanner(System.in);
System.out.print("Enter the number: ");
int number = input.nextInt();
if (number % 5 == 0)
System.out.println("Divisible by 5");
else if (number % 3 == 0)
System.out.println("Divisible by 3");
else
System.out.println("not divisible by 3 or 5");
System.out.println("Wanna do it again??(y/n)");
String response = input.nextLine();
if(response=="n")
break;
}
}
}