Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


prajapti harin raj
using function
2 Answer(s)      a year and 11 months ago
Posted in : Java Beginners


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


Advertisement
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
function
function  difference between function overloading and operator overloading
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
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
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
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
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
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
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
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
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
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
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 <
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...; PHP Var_dump Function Example 1: <?php $a=array(1,2,'c',true,array
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
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
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
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
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
What is the use of friend function?
What is the use of friend function?  What is the use of friend function
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
example of function overriding in c++
example of function overriding in c++  require an example of function overriding in c
variable function in php
variable function in php  Can any one tell me how to write a variable function in PHP
post function php
post function php  when should i use post function in PHP
onmouseover function in maparea
onmouseover function in maparea  Hello, I have a website that is using multiple maps that are working fine. I would like to change the title of the maparea in a onmouseover function showing a image. I have tried many things
MySql function - SQL
MySql function  Hi sir/madam, I am creating a function in mysql5.0... correspinding to your MySQL version for right systax' I am using MySQL5.0 version...: ---------------------------- DELIMITER $$ CREATE FUNCTION description(crd_type CHAR(6),amount
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
The strlen() function
The strlen() function The strlen() function is used to find the length of a string. Syntax is given below : strlen(string) The below example gives you a clear idea : Example : <?php echo strlen("Welcome
The $_GET Function
The $_GET Function The $_GET function in PHP is used to gather data of form submit with method="get". The data sent using get method is visible... of submitted form in a PHP page using $_GET method as follows : Your Name :<?php
Eval Function in PHP
Eval Function in PHP  Hello PHP experts, Please tell me about Eval() Function in PHP. How to use Eva() function in PHP? Thanks   Hi, The Eval() function is PHP is very handy. It allows to you store the PHP code
Function split() is deprecated
Function split() is deprecated  Hi, The Function split() is deprecated in latest version of PHP 5.5.23? What is the solution? Thanks   Hi, Use the following function: array explode ( string $delimiter , string
hash function for java strings
hash function for java strings  hash function for java strings   int hash=7; for (int i=0; i < strlen; i++) { hash = hash*31+charAt(i
method and function difference
method and function difference  so far, I understand that method and function are the same thing... but is there any difference between the two terms? Please explain me if both are different terms. Thanks in advance
Advertisements
 

 

 

DMCA.com