viernes, 21 de octubre de 2011

Mayúsculas Minúsculas - Java

 1 package mayusculasminusculas;
 2 
 3 import java.io.BufferedReader;
 4 import java.io.IOException;
 5 import java.io.InputStreamReader;
 6 
 7 
 8 public class MayusculasMinusculas 
 9 {
10     public static void main(String[] args) throws IOException 
11     {
12         String texto;
13         String texto_aux="";
14         int i;
15         
16         InputStreamReader ISR = new InputStreamReader(System.in);
17         BufferedReader bftexto = new BufferedReader(ISR);
18         
19         texto = bftexto.readLine();
20         
21         System.out.println("En mayusculas "+texto.toUpperCase());
22         System.out.println("En minusculas "+texto.toLowerCase());
23         
24         for (i=0;i<texto.length();i++)
25             texto_aux = texto_aux + texto.toUpperCase().charAt(i);
26         
27         System.out.println("En mayusculas "+texto_aux);
28         
29         texto_aux = "";
30         for (i=0;i<texto.length();i++)
31             texto_aux = texto_aux + texto.toLowerCase().charAt(i);
32         
33         System.out.println("En minusculas "+texto_aux);
34  
35         texto_aux = "";
36         for (i=0;i<texto.length();i++)
37             if (Character.isUpperCase(texto.charAt(i)))
38                 texto_aux = texto_aux + texto.toLowerCase().charAt(i);
39             else
40                 texto_aux = texto_aux + texto.toUpperCase().charAt(i);
41         
42         System.out.println("Case cambiado "+texto_aux);
43         
44         texto_aux = "";
45         for (i=0;i<texto.length();i++)
46             if (esVocal(texto.charAt(i)))
47                 texto_aux = texto_aux + texto.toUpperCase().charAt(i);
48             else
49                 texto_aux = texto_aux + texto.toLowerCase().charAt(i);
50         
51         System.out.println("Case cambiado "+texto_aux);
52         
53                
54          
55     }
56     
57     public static  Boolean esVocal(Character caracter)
58     {
59         String vocales = "aeiouAEIOU";
60         
61         if (vocales.indexOf(caracter)==-1)
62             return false;
63         else
64             return true;
65     }
66 }

No hay comentarios:

Publicar un comentario