Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class cuenta_vocales_par{
- public static void main (String args[]) {
- String frase;
- int V=0;
- int VT=0;
- int F=-1;
- while(V%2==0){
- VT = VT+V;
- frase = leeFrase();
- V = calculaVocales(frase);
- System.out.println("La frase contiene "+V+" vocales.");
- F++;
- }System.out.println("Vocales total encontradas: "+VT+". Cantidad de frases con cant. vocales pares: "+F);
- }
- public static String leeFrase(){
- Scanner tec = new Scanner(System.in);
- boolean Func = true;
- String frase = "";
- while (Func){
- System.out.print("Ingrese una frase: ");
- frase = tec.nextLine();
- Func=validaFrase(frase);
- }return frase;
- }
- public static boolean validaFrase(String f){
- for(int i = 0;i<f.length();i++){
- if(f.charAt(i)!=' '){
- return false;
- }
- }System.out.println("Error. Frase no valida.");
- return true;
- }
- public static int calculaVocales(String f){
- int cont = 0;
- for(int i = 0;i<f.length();i++){
- if(f.charAt(i)=='a'||f.charAt(i)=='e'||f.charAt(i)=='i'||f.charAt(i)=='o'||f.charAt(i)=='u'){
- cont++;
- }
- }return cont;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement