-
Lenguaje
Java usando Scanner
-
Descripción
Leer tres números enteros de un dígito y almacenarlos en una sola variable que contenga a esos tres dígitos. Por ejemplo si A=5 y B=6 y C=2 entonces X=562.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.Scanner;
public class TresNumerosEnterosDeUnDigito {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int A, B, C, X;
System.out.print("Ingresa el valor de A: ");
A = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de B: ");
B = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de C: ");
C = in.nextInt();
in.nextLine();
X=A*100+B*10+C;
System.out.println("Valor de X: " + X);
}
}
public class TresNumerosEnterosDeUnDigito {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int A, B, C, X;
System.out.print("Ingresa el valor de A: ");
A = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de B: ");
B = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de C: ");
C = in.nextInt();
in.nextLine();
X=A*100+B*10+C;
System.out.println("Valor de X: " + X);
}
}