-
Lenguaje
Java usando Scanner
-
Descripción
Obtiene el producto de dos números enteros positivos mediante sumas sucesivas.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
public class ProductoMedianteSumasSucesivas {
public static void main(String[] args) {
int i, m, n, producto;
producto = 0;
System.out.print("Ingresa el valor de m: ");
m = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de n: ");
n = in.nextInt();
in.nextLine();
for (i=1; i<=n; i++) {
System.out.print("PROCESO " + i);
producto=producto+m;
System.out.println();
}
System.out.println("Valor de producto: " + producto);
}
}
public class ProductoMedianteSumasSucesivas {
public static void main(String[] args) {
int i, m, n, producto;
producto = 0;
System.out.print("Ingresa el valor de m: ");
m = in.nextInt();
in.nextLine();
System.out.print("Ingresa el valor de n: ");
n = in.nextInt();
in.nextLine();
for (i=1; i<=n; i++) {
System.out.print("PROCESO " + i);
producto=producto+m;
System.out.println();
}
System.out.println("Valor de producto: " + producto);
}
}