Ghala X:
* Quiero la cuestión de repetir, pero si el usuario ha introducido -1 quiero que el programa deje? *
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 + " ");
}
}
}
}
}