-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharReader
39 lines (32 loc) · 1.07 KB
/
charReader
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
32
33
34
35
36
37
38
39
package ejercicioslibro;
import java.lang.Math;
public class diferenciadorLetras{
// This is not the best way to do it but is an exercise to show how if,else if and else works,so...
// Will be better to create a function or put all "else if" in one row using OR
public static void main (String[] args){
char valor1;
valor1=(char)(Math.random()*26+'a');
if(valor1=='a'){
System.out.println("Es una vocal");
System.out.println(valor1);
}
else if(valor1=='e'){
System.out.println("Es una vocal");
System.out.println(valor1);
}
else if(valor1=='i'){
System.out.println("Es una vocal");
System.out.println(valor1);
}
else if(valor1=='o'){
System.out.println("Es una vocal");
System.out.println(valor1);
}
else if(valor1=='u'){
System.out.println("Es una vocal");
System.out.println(valor1);
}else{
System.out.println("Es una consonante");
System.out.println(valor1);}
}
}