私は質問を繰り返したいが、ユーザが入力した場合-1私は停止にプログラムをしたいですか?

ガーラX:

*私は質問を繰り返したいが、ユーザが入力した場合-1私は停止にプログラムをしたいですか?*

public class Q2 { 
public static void main (String [] args) { 
int N ;  
Scanner input = new Scanner (System.in) ; 
System.out.println("Enter an integer to print it's multiplication table, -1 to exit ") ;
N = input.nextInt() ; 

switch (N) {
case -1 :   break ;   
default :
for (int t=1 ; t <= N ; t++){
System.out.println (" Multiplication table of " + t );
for ( int i = 0 ; i <= 10 ; i++ ) { 
System.out.println ( t + "*" + i + " = " + i*t + " ");}}}





}}

Ta_Req:
import java.util.Scanner;

public class ContiniousProgramme {

    public static void main(String [] args ) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int N = sc.nextInt();
            if(N == -1) {
                break;
            }
            for (int t=1 ; t <= N ; t++){
                System.out.println (" Multiplication table of " + t );
                for ( int i = 0 ; i <= 10 ; i++ ) { 
                    System.out.println ( t + "*" + i + " = " + i*t + " ");
                }
            }
        }
    }
}

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=277753&siteId=1