using function

using function

write a program using function overloading to accept any sentence and print vowels and consonants sepratly

View Answers

September 10, 2012 at 12:43 PM

Here is an example that accepts a sentence from the user and display the vowels and consonants from that string.

import java.io.*;
class Overload
{
    void findVowelsAndConsonants(String str)
    {
        char ch=' ';  
        System.out.println("Vowels are: ");
     for (int i=0;i<str.length();i++)
     {
         ch = str.charAt(i); 

      if(( ch == 'a') ||( ch == 'e') ||( ch == 'i') ||( ch == 'o') ||( ch == 'u')){
        System.out.println(ch);
    }
     }
     System.out.println("Consonants are: ");
     for (int i=0;i<str.length();i++)
     {
          ch = str.charAt(i); 
         if(( ch == 'a') ||( ch == 'e') ||( ch == 'i') ||( ch == 'o') ||( ch == 'u')){
         }

          else{
              System.out.println(ch); 
          }

      }
    }

    void findVowelsAndConsonants(){
    }

    }
public class VowelsAndConsonants{
public static void main(String[] args)throws IOException
{

try
{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Enter string: ");
    String str=br.readLine();
    Overload o=new Overload();
    o.findVowelsAndConsonants(str);
    o.findVowelsAndConsonants();


}
catch (Exception e) {
    System.err.println(e);
  }

    }

}

September 10, 2012 at 12:45 PM

Here is an example that accepts a sentence from the user and display the vowels and consonants from that string.

import java.io.*;
class Overload
{
    void findVowelsAndConsonants(String str)
    {
        char ch=' ';  
        System.out.println("Vowels are: ");
     for (int i=0;i<str.length();i++)
     {
         ch = str.charAt(i); 

      if(( ch == 'a') ||( ch == 'e') ||( ch == 'i') ||( ch == 'o') ||( ch == 'u')){
        System.out.println(ch);
    }
     }
     System.out.println("Consonants are: ");
     for (int i=0;i<str.length();i++)
     {
          ch = str.charAt(i); 
         if(( ch == 'a') ||( ch == 'e') ||( ch == 'i') ||( ch == 'o') ||( ch == 'u')){
         }

          else{
              System.out.println(ch); 
          }

      }
    }

    void findVowelsAndConsonants(){
    }

    }
public class VowelsAndConsonants{
public static void main(String[] args)throws IOException
{

try
{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Enter string: ");
    String str=br.readLine();
    Overload o=new Overload();
    o.findVowelsAndConsonants(str);
    o.findVowelsAndConsonants();


}
catch (Exception e) {
    System.err.println(e);
  }

    }

}

Ads









Related Tutorials/Questions & Answers:
using function
using function   using a function to find the value of v from the foiiowing expression 1v=1u+1*f
using function
using function  write a program using function overloading to accept any sentence and print vowels and consonants sepratly   Here is an example that accepts a sentence from the user and display the vowels and consonants
Advertisements
multiplication function in jsp using scriptlet function
multiplication function in jsp using scriptlet function   how...">--> <script type="text/javascript"> function txtnull...; if(a=="") { alert("insert data"); } } function sum(txt
validation of strings using java function
validation of strings using java function  hi all, i am uploading data from csv file to data base where i took student id as string of length 6 char of the form abc123 will you please give me a function to validate this field
sum and avg function using HQL.
sum and avg function using HQL.  How to use sum and avg function... of them. sum() function returns summation of specified field in the table. avg() function returns average of specified field in the table. Example
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
How ro convert char into string using recursive function in c#??
How ro convert char into string using recursive function in c#??  This coding is for java...but i want this in c# How ro convert char into string using recursive function in c#?? char [] ch={'H','E','L','L','o'}; TO ans
Program to Find Cube Root of any Number without using built in function
Program to Find Cube Root of any Number without using built in function  Please help me in finding cube root of any number without using Built in function in java
populating textbox value from the database using onchange function,
populating textbox value from the database using onchange function,  hi, Everyone I have a problem regarding poulatinng the value in textbox after... downlist it call onchange function with the selected value.. my issue issue
function
function  difference between function overloading and operator overloading
In JSP page, inside a javascript function, can I place a java code using scriptlet tag?
In JSP page, inside a javascript function, can I place a java code using... checkListValue() using scriptlet tag inside the javascript function closeWind... is trying to close a window, I am calling a java script function closeWind
How to calculate minimum in Hibernate using the min() Function
How to calculate minimum in Hibernate using the min() Function The min() function of Hibernate API translates it to the SQL query and execute it against.... In this tutorial we will use the min() function in Hibernate and run
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
Calling a function
Calling a function  Hi, I have a function xyz() in php code. When a button is clicked it should execute that particular function for that i have... function function xyz() { } but this is not working can u tell me
function method
function method  input Rs. 12000 Discount= 10%, 8% = Rs.(12000-1200) = Rs.(10800-864) = Rs. 9936
function method
function method  input Rs. 12000 Discount= 10%, 8% = Rs.(12000-1200) = Rs.(10800-864) = Rs. 9936
If function in PHP
If function in PHP  Hi, Provide me the example of If function in PHP. Thanks   Hi, If function is PHP is used to check for some condition and the execute a block of code. He is an example of if() function in PHP
disable function
disable function  Sir, I have called a java script function when one radio button is checked i want to disable this function when another radio button is checked ,both radio buttons are of same group Please help Thanks in advance
Array Sizeof Function PHP
Array Sizeof Function PHP  Hi, How to count the number of elements in an array using the PHP Array sizeof() function? Please provides me online help links or example of array sizedof() PHP. Thanks
unoin function
unoin function  how to define a union function in java?(ex:a=a U b) how to write tha java code?give ex.   Java Union Function You have learnt union, intersection etc in Sets. Here the given code finds the union of two
function method
function method  i. void display(String str.int p)with one string... is an example where we have created a function that accepts a string and an integer...); } }   Here is an example where we have created a function that accepts
javascript abort function
javascript abort function   I am running a loop and wants to abort it after a specific time. How is it possible using JavaScript Abort function..?   Using JavaScript we can abort function or loop. See the the code below
Function pointer in c
Function pointer in c  What is the difference between function call with function pointer and without function pointer(normal function call
Where is the lit() function in pyspark 2.2.0?
Where is the lit() function in pyspark 2.2.0?  Hi, I want to use the lit function in PySpark program. I am using Spark 2.2.0. Where is the lit() function in pyspark 2.2.0? Thanks
PHP idate() Function
help related to PHP idate() Function. I waiting for your valuable suggestion. Thanks,   Hi, The idate() Function in PHP will returns a string formatted according to the format string using the integer timestamp or the current
basic function of computer system
basic function of computer system  What is the basic function of computer system
call function in php
call function in php  What is the call function in PHP please explain
variable function in php
variable function in php  Can any one tell me how to write a variable function in PHP?   Go through the PHP Variable function tutorial ... PHP Variable Function

Ads