"required int" error when executing code [closed]

0

I made this small program, where I want to loop, while the user chooses to register more messages.

The error, after compiling the code, says:

  

required: int
  found: no arguments
  reason: actual and formal argumente lists differ in lenght.

Here is the snippet of code:

/*
 * Class do registo de mensagens
 */
import java.util.*;
public class RegistoDeMenssagem1 
{           
   public static void main(String[] args) 
   {  
       System.out.println("Bem vindo Utilizador"); 
        System.out.println("Introduza o número da recarga"); 
        Scanner kb = new Scanner(System.in);
         int Recarga = kb.nextInt();  //criar o mêtodo que verifica se trata-se de int.
        String resposta;
        boolean sn;

     {
    System.out.println("Têm mais recarga para registar?");   
    System.out.println("responda 'S´ para continuar ou 'N´ para terminar");
     resposta = kb.nextLine().trim().toLowerCase();
    if (resposta.equals("s")) 
        {
            sn = true;
            System.out.println("Introduza o número da recarga"); 
            Scanner kb2 = new Scanner(System.in);
            int MaisRecarga = kb.nextInt(); //Aqui criar o exception handler que verifique tratar-se de int.
        System.out.println("Têm mais alguma recarga para registar?");   

    } 
    else if (resposta.equals("n"))
        {
            System.out.println("Obrigado, atê a próxima!");
                System.exit();
    }
     }

   }
}
    
asked by anonymous 15.09.2016 / 15:32

2 answers

3

The static method call System.exit(int status) requires that a type int be passed as an argument, which identifies the type of the execution end status.

If the termination was normal (it was not because of some exception or other unexpected situation), you can pass 0 as an argument. If there were any errors, you can pass another value other than zero.

Change this line to System.exit(0); , since with your code, the problem is terminating normally.

References:

15.09.2016 / 15:52
2

try this:

System.exit(0);

it expects an int parameter to execute

Look:

link

    
15.09.2016 / 15:55