-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_Break_Continue.java
More file actions
31 lines (26 loc) · 1.05 KB
/
Java_Break_Continue.java
File metadata and controls
31 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
public class Java_Break_Continue {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Se mostrarán los resultados que no son múltiplos del número ingresado");
System.out.print("Ingrese el valor inicial : ");
int a = scan.nextInt();
System.out.print("Ingrese el valor final : ");
int b = scan.nextInt();
System.out.println("Ingrese el número del que no quiere que mostremos sus múltiplos");
int num = scan.nextInt();
System.out.println("Los Numeros son : ");
for (int i = a; i <= b; i++) {
//Si i es la mitad de la suma de los dos ingresados se rompe el bucle
if(i == (a+b)/2){
System.out.println("Algo ha ocurrido, el bucle se rompio!!!");
break;
}
//Si es multiplo lo obvia y pasa a la siguiente iteración
if(i % num == 0){
continue;
}
System.out.println(i);
}
}
}