• R/O
  • SSH
  • HTTPS

dam1t: Commit


Commit MetaInfo

Revision9 (tree)
Zeit2018-12-20 18:21:20
Autorhflorido

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- DAM1T-UF1/P6_Actividad5/_CorreccionP6/ExAmp1.java (revision 8)
+++ DAM1T-UF1/P6_Actividad5/_CorreccionP6/ExAmp1.java (revision 9)
@@ -7,7 +7,6 @@
77 public static void main(String[] args) {
88 int number;
99 int cont = 0;
10- int pos = 0;
1110 boolean isIn;
1211 int[] array = new int[26];
1312
--- DAM1T-UF1/P6_Actividad5/_CorreccionP6/ExAmp2.java (revision 8)
+++ DAM1T-UF1/P6_Actividad5/_CorreccionP6/ExAmp2.java (revision 9)
@@ -1,5 +1,6 @@
11 package _CorreccionP6;
22
3+import java.util.Random;
34 import java.util.Scanner;
45
56 public class ExAmp2 {
@@ -6,9 +7,32 @@
67 public static void main(String[] args) {
78 Scanner data = new Scanner(System.in);
89
9- String[] menu = new String[] {"OPCION A: NUMERO ALEATORI","OPCIO B: LLETRA ALEATORIA"};
10+ boolean exit = false;
1011
12+ char[] letras = new char[] {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
13+ int[] numeros = new int[] {0,1,2,3,4,5,6,7,8,9};
1114
12-
15+ do {
16+
17+ System.out.print("OPCION A: NUMERO ALEATORI\nOPCIO B: LLETRA ALEATORIA\nOPCIO:");
18+ char option = data.nextLine().charAt(0);
19+
20+ switch (option) {
21+ case 'A':
22+ System.out.println(numeros[(new Random()).nextInt(10)]);
23+ break;
24+
25+ case 'B':
26+ System.out.println(letras[(new Random()).nextInt(26)]);
27+ break;
28+
29+ case 'S':
30+ exit = true;
31+ break;
32+
33+ default:
34+ System.out.println("ERROR");
35+ }
36+ } while (!exit);
1337 }
1438 }
Show on old repository browser