scan does not capture word with accent

0

I'm doing the following exercise:

  

Create an application that prompts the user for an integer and then asks if the number they enter is greater than zero. By analyzing the number reported and the user response, the application should determine whether the response is true or false.

In this exercise I can use only arithmetic, comparison, wrapper, and ternary operators. My code looks like this:

public class Exercicio0605 {

public static void main(String[] args) {

    PrintStream saida = System.out;
    Scanner scan = new Scanner(System.in, "UTF-8");
    String sim = "sim";
    String nao = "não";
    String resposta = new String(); 
    String verifica = new String();
    int num;

    saida.print("Informe um numero inteiro:\t");
    num = scan.nextInt();
    scan.nextLine();
    saida.println("O número é maior que zero?\t");
    resposta = scan.nextLine();

    verifica =  (num > 0 && resposta.equalsIgnoreCase(sim)) || 
            (num < 0 && resposta.equalsIgnoreCase(nao)) ? String.valueOf("Verdadeira") :
            String.valueOf("Falsa");

    saida.println("A sua resposta é:\t" + verifica);

}

}

The program works almost normally. The problem is that when I report a negative value and I answer that it is not greater than zero, the program always returns false. However, if you change the value of the string not to "no" (without an accent, String does not="no";) and respond without using an accent it informs true.

What can cause this?

    
asked by anonymous 13.07.2017 / 23:40

0 answers