(empty log message)
@@ -0,0 +1,26 @@ | ||
1 | +package OscarRomero; | |
2 | + | |
3 | +import java.util.Scanner; | |
4 | + | |
5 | +public class Ej2 { | |
6 | + | |
7 | + public static void main(String[] args) { | |
8 | + | |
9 | + int suma = 0; | |
10 | + boolean check = false; | |
11 | + | |
12 | + Scanner a = new Scanner(System.in); | |
13 | + | |
14 | + do { | |
15 | + System.out.print("LLETRA: "); | |
16 | + char value = a.next().charAt(0); | |
17 | + if (value != 's' && value != 'S') { | |
18 | + suma++; | |
19 | + } else { | |
20 | + check = true; | |
21 | + } | |
22 | + | |
23 | + } while (!check); | |
24 | + System.out.print(suma); | |
25 | + } | |
26 | +} |
@@ -0,0 +1,33 @@ | ||
1 | +package OscarRomero; | |
2 | + | |
3 | +import java.util.Scanner; | |
4 | + | |
5 | +public class Ej3 { | |
6 | + | |
7 | + public static void main(String[] args) { | |
8 | + | |
9 | + double num, suma = 0, media = 0; | |
10 | + boolean check = false; | |
11 | + Scanner a = new Scanner(System.in); | |
12 | + | |
13 | + do { | |
14 | + System.out.print("Numero: "); | |
15 | + num = a.nextDouble(); | |
16 | + if (num >= 0) { | |
17 | + suma = suma + num; | |
18 | + media++; | |
19 | + } else { | |
20 | + check = true; | |
21 | + } | |
22 | + } while (!check); | |
23 | + | |
24 | + if (media > 0) { | |
25 | + media = suma / media; | |
26 | + System.out.print("Suma: " + suma); | |
27 | + System.out.print("Media: " + media); | |
28 | + } else { | |
29 | + System.out.println("No hay ningun valor"); | |
30 | + | |
31 | + } | |
32 | + } | |
33 | +} | |
\ No newline at end of file |
@@ -0,0 +1,26 @@ | ||
1 | +package OscarRomero; | |
2 | + | |
3 | +import java.util.Scanner; | |
4 | + | |
5 | +public class Ej4 { | |
6 | + | |
7 | + public static void main(String[] args) { | |
8 | + | |
9 | + int num; | |
10 | + | |
11 | + Scanner a = new Scanner(System.in); | |
12 | + System.out.print("Numero: "); | |
13 | + num = a.nextInt(); | |
14 | + | |
15 | + if (num > 0 && num < 50) { | |
16 | + do { | |
17 | + num *= 2; | |
18 | + System.out.println(num); | |
19 | + } while (num < 100); | |
20 | + } else { | |
21 | + System.out.print("El numero no es valido"); | |
22 | + } | |
23 | + | |
24 | + } | |
25 | + | |
26 | +} |
@@ -0,0 +1,26 @@ | ||
1 | +package OscarRomero; | |
2 | + | |
3 | +import java.util.Scanner; | |
4 | + | |
5 | +public class Ej6 { | |
6 | + | |
7 | + public static void main(String[] args) { | |
8 | + | |
9 | + int A, num = 1; | |
10 | + | |
11 | + Scanner a = new Scanner(System.in); | |
12 | + System.out.print("Numero: "); | |
13 | + A = a.nextInt(); | |
14 | + | |
15 | + for (int i = 1; i <= A; i++) { | |
16 | + for (int b = 0; b < i; b++) { | |
17 | + System.out.print(num + " "); | |
18 | + num++; | |
19 | + } | |
20 | + System.out.print("\r"); | |
21 | + num = 1; | |
22 | + } | |
23 | + | |
24 | + } | |
25 | + | |
26 | +} |
@@ -0,0 +1,28 @@ | ||
1 | +package OscarRomero; | |
2 | + | |
3 | +import java.util.Scanner; | |
4 | + | |
5 | +public class Ej8 { | |
6 | + | |
7 | + public static void main(String[] args) { | |
8 | + int value, A = 0; | |
9 | + Scanner a = new Scanner(System.in); | |
10 | + System.out.print("Numero: "); | |
11 | + value = a.nextInt(); | |
12 | + if (value > 0 && value < 10) { | |
13 | + for (int i = 1; i <= value; i++, A = 0) { | |
14 | + for (int b = 1; b <= value - i; b++) { | |
15 | + System.out.print(" "); | |
16 | + } | |
17 | + while (A != 2 * i - 1) { | |
18 | + System.out.print("* "); | |
19 | + A++; | |
20 | + } | |
21 | + System.out.println(); | |
22 | + } | |
23 | + } else { | |
24 | + System.out.print("ERROR"); | |
25 | + } | |
26 | + } | |
27 | + | |
28 | +} |