java loop to repeat program

前端 未结 3 382
余生分开走
余生分开走 2021-01-28 07:17

I am extremely new to java I am in my second week in classes or so--

I need my program to keep going or exit according to the user. It is a payroll calculation and I wan

3条回答
  •  我在风中等你
    2021-01-28 07:46

    Here's a guide for you..

    You can create a method for the transaction.

    //Place this on your main method
    do{
       //call the method
        transaction();  
       //ask if the user wants to repeat the program
       System.out.print("Do you want to continue (y/n)");
       input = reader.nextLine(); 
    }while(input.equalsIgnoreCase("Y"))
    

    public void transaction(){
       //your transaction code here.. 
    }
    

提交回复
热议问题