5th sem OOPJ Create a class which asks the user to enter a sentence, and it should display count of each vowel type in the sentence. The program should continue till user enters a word “quit”. Display the total count of each vowel for all sentences.


import java.util.*;

/**
 *
 * @author Yash
 */

public class pra8 {
public static void main(String arg[]){
        String s1 = new String();
       
        while(!s1.equals("quit")){
        char ch;
        int vol=0,cont=0;
        System.out.println("Enter the String..");
        Scanner sc = new Scanner(System.in);
        s1 = sc.nextLine();
        StringBuffer sb = new StringBuffer(s1);
        for(int i=0;i<sb.length();i++){
            ch = sb.charAt(i);
            if( ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch=='u' || ch=='U'){
                vol++;
            }else{
                cont++;
            }
        }
        System.out.println("voweles : "+vol);
        System.out.println("Consonants :" +cont);
        }
    }  
}

Comments

Popular posts from this blog

5th sem OOPJ Write an interactive program to print a diamond shape. For example, if user enters the number 3, the diamond will be as follows:

SQL Lab1: Create a Database Table for DayCare

SQL Lab 11