Skip to content

Commit d98d080

Browse files
committed
01 - Java
1 parent 421e7c7 commit d98d080

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
public static void main(String[] args) {
2+
3+
// Crea ejemplos utilizando todos los tipos de operadores de tu lenguaje:
4+
5+
// ASIGNACIÓN
6+
int a = 5;
7+
int b = 10;
8+
System.out.println(a += 2);
9+
System.out.println(a -= 2);
10+
System.out.println(a /= 2);
11+
System.out.println(a *= 2);
12+
System.out.println(++a);
13+
System.out.println(--a);
14+
15+
// ARITMÉTICOS
16+
System.out.println(a + b);
17+
System.out.println(a - b);
18+
System.out.println(a * b);
19+
System.out.println(a / b);
20+
System.out.println(a % b);
21+
22+
// RELACIONALES
23+
System.out.println(a == b);
24+
System.out.println(a <= b);
25+
System.out.println(a >= b);
26+
System.out.println(a < b);
27+
System.out.println(a > b);
28+
System.out.println(a != b);
29+
30+
31+
// LÓGICOS
32+
System.out.println(a+a==b && b-a==a);
33+
System.out.println(a+a==b || b-a==a);
34+
System.out.println(a+a==b & b-a==a);
35+
System.out.println(a+a==b | b-a==a);
36+
System.out.println(!(a+a==b || b-a==a));
37+
38+
/*
39+
ESTRUCTURAS SELECTIVAS
40+
*/
41+
42+
// CICLO IF
43+
44+
if(a > b){
45+
System.out.println("La variable A es igual a: " + a);
46+
System.out.println("La variable B es igual a: " + b);
47+
System.out.println("La variable A es mayor que B");
48+
}
49+
50+
// CICLO ELSE IF
51+
else if(a == b){
52+
System.out.println("Las variables A y B son iguales");
53+
}
54+
55+
// CICLO ELSE
56+
else{
57+
System.out.println("La variable A es igual a: " + a);
58+
System.out.println("La variable B es igual a: " + b);
59+
System.out.println("La variable B es mayor que A");
60+
}
61+
62+
// CICLO SWITCH
63+
64+
switch (a) {
65+
case 1:
66+
System.out.println("La variable A es igual a 1");
67+
break;
68+
case 2:
69+
System.out.println("La variable A es igual a 2");
70+
break;
71+
case 3:
72+
System.out.println("La variable A es igual a 3");
73+
break;
74+
case 4:
75+
System.out.println("La variable A es igual a 4");
76+
break;
77+
case 5:
78+
System.out.println("La variable A es igual a 5");
79+
break;
80+
case 6:
81+
System.out.println("La variable A es igual a 6");
82+
break;
83+
case 7:
84+
System.out.println("La variable A es igual a 7");
85+
break;
86+
default:
87+
System.out.println("La variable A es mayor a 7");
88+
break;
89+
}
90+
91+
92+
/*
93+
ESTRUCTURAS REPETITIVAS
94+
*/
95+
96+
//ESTRUCTURA WHILE
97+
98+
while(b == 10){
99+
System.out.println("La variable B es igual a: " + b);
100+
--b;
101+
102+
}
103+
104+
105+
//ESTRUCTURA DO-WHILE
106+
107+
do{
108+
System.out.println("La variable A es igual a: " + a + " y es mayor que 0");
109+
a--;
110+
} while(a > 0);
111+
112+
113+
114+
//ESTRCUTURA FOR
115+
for(a=0;a<5;a++){
116+
System.out.println("La variable a es igual a: " + a + " y es menor a 5");
117+
}
118+
119+
// EJERCICIO EXTRA
120+
int c = 10;
121+
for (c=10;c >= 10 && c <= 55;c++){
122+
if(c%2 == 0 && c%3 != 0 && c != 16){
123+
System.out.println(c);
124+
}
125+
126+
}
127+
}

0 commit comments

Comments
 (0)