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);
  }

    }

}









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
Handle mail function using JSP & Servlet
Handle mail function using JSP & Servlet  Dear Sir, for my final year project i want to add email function to confirm registration & confirm appointment. I'm using JSP & Servlet and apache web server. I'm developing
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 can we get second of the current time using date function?
How can we get second of the current time using date function?  How can we get second of the current time using date function
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
Printing the String value using NSLog function
In this section you will learn how you can print the value of NSString using the NSLog function. In the following code example we will show you how you can easily output the value of NSString variable using the NSLog function
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
isNaN function
isNaN function  What does isNaN function do
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
If function in PHP
If function in PHP  Hi, Provide me the example of If function in PHP. ThanksADS_TO_REPLACE_1   Hi, If function is PHP is used to check... of if() function in PHP:ADS_TO_REPLACE_2 $book="PHP"; if($book=="PHP"){ echo "Book
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
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
Formatting the out put in NSLog function
You can easily format the values of int, float, double and long while using the NSLog function. Here is the example of formatting int, float, double and long values. // //  PrintFormat.h //  DataTypes // // #import <
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
PHP var_dump function
PHP var_dump Function The PHP var_dump() function displays information about one or more than one expressions in structured way that includes its type... to exportADS_TO_REPLACE_2   PHP Var_dump Function Example 1: <
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
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
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
What is the use of friend function?
What is the use of friend function?  What is the use of friend function
call function in php
call function in php  What is the call function in PHP please explain
basic function of computer system
basic function of computer system  What is the basic function of computer system
jsp function - JSP-Servlet
jsp function  how to make function in jsp... i want example of jsp method or function in which on button click function get data fron database... an Example We can write functions or methods into JSP using the Declaratives tags
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
java password function
java password function  secret password function
post function php
post function php  when should i use post function in PHP
variable function in php
variable function in php  Can any one tell me how to write a variable function in PHP
example of function overriding in c++
example of function overriding in c++  require an example of function overriding in c
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? (adsbygoogle = window.adsbygoogle || []).push
ModuleNotFoundError: No module named 'to_function'
ModuleNotFoundError: No module named 'to_function'  Hi, My Python... 'to_function' How to remove the ModuleNotFoundError: No module named 'to_function' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'with-as-a-function'
ModuleNotFoundError: No module named 'with-as-a-function'  Hi, My... named 'with-as-a-function' How to remove the ModuleNotFoundError: No module named 'with-as-a-function' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'function'
ModuleNotFoundError: No module named 'function'  Hi, My Python... 'function' How to remove the ModuleNotFoundError: No module named 'function... to install padas library. You can install function python with following
What is the microtime() Function PHP ?
What is the microtime() Function PHP ?   Hi, What is microtime() Function in PHP? What is the role of Microtime() Function in PHP. Please suggest me any online reference. Thanks
php array length function
php array length function  writing a php array length function
main function in java - Java Interview Questions
main function in java  1....why is function main() define as static in java? 2...drawbacks of using rmi
Bind custom event with an element using 'bind'
Bind custom event with an element using 'bind' In this tutorial, we will discuss about how to bind a user define event with an element using 'bind ' function of jQuery. In this example ,  we are firing an user

Ads