-
Lenguaje
Java usando Scanner
-
Descripción
Dado dos números enteros, hallar la suma: S = n1 + n2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import java.util.Scanner;
public class N1MasN2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double S, n1, n2;
System.out.print("Ingresa el valor de n1: ");
n1 = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de n2: ");
n2 = in.nextDouble();
in.nextLine();
S=n1+n2;
System.out.println("Valor de S: " + S);
}
}
public class N1MasN2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double S, n1, n2;
System.out.print("Ingresa el valor de n1: ");
n1 = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de n2: ");
n2 = in.nextDouble();
in.nextLine();
S=n1+n2;
System.out.println("Valor de S: " + S);
}
}