-
Lenguaje
Java usando Scanner
-
Descripción
Lee un valor N y determina si es múltiplo común de X y Z donde X y Z también se ingresan por teclado.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
public class NMultiploDeXYZ {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N, X, Z;
System.out.print("Ingresa el valor de N: ");
N = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de X: ");
X = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de Z: ");
Z = in.nextInt();
in.nextLine();
if(X%N==0&&Z%N==0)
System.out.println("N es m\u00FAltiplo com\u00FAn de X y Z.");
else
System.out.println("N no es m\u00FAltiplo com\u00FAn de X y Z.");
}
}
public class NMultiploDeXYZ {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N, X, Z;
System.out.print("Ingresa el valor de N: ");
N = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de X: ");
X = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de Z: ");
Z = in.nextInt();
in.nextLine();
if(X%N==0&&Z%N==0)
System.out.println("N es m\u00FAltiplo com\u00FAn de X y Z.");
else
System.out.println("N no es m\u00FAltiplo com\u00FAn de X y Z.");
}
}