Question: function method

Ads

 
 
 

Share on Google+Share on Google+

partha karmakar
function method
2 Answer(s)      4 years and 9 months ago
Posted in : Java Beginners

i. void display(String str.int p)with one string argment and one integer argument. it display all the upper character if 'p' is 1(one)otherwise, display all the lowercase characters. ii. void display (String str, char chr) with one String argument and one character argument. It display all the vowels if chr is 'v' otherwise, finds its cube.

Ads
View Answers

July 30, 2012 at 10:54 AM


Here is an example where we have created a function that accepts a string and an integer value and perform a upper case and lowercase method to the string.

import java.util.*;
class FunctionExample 
{
    void display(String str,int p){
        if(p==1){
            System.out.println(str.toUpperCase());
        }
        else{
            System.out.println(str.toLowerCase());
        }
    }

    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter string: ");
        String st=input.next();
        System.out.print("Enter integer: ");
        int i=input.nextInt();
        FunctionExample f=new FunctionExample();
        f.display(st,i);
    }
}


July 30, 2012 at 11:09 AM


Here is an example where we have created a function that accepts a string and a character value.

import java.util.*;
class FunctionExample 
{
    void display(String str,char chr){
        if(chr=='v'){
                String vowels = "aeiouAEIOU";
                String res="";
                for( int i = 0; i < str.length(); i++ )
                if( vowels.indexOf( str.charAt( i ) ) != -1 )
                res=res+str.charAt( i );
            System.out.println("Vowels are: "+res);
        }
    }

    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter string: ");
        String st=input.next();
        System.out.print("Enter character: ");
        char ch=input.next().charAt(0);
        FunctionExample f=new FunctionExample();
        f.display(st,ch);
    }
}

Ads









Related Tutorials/Questions & Answers:
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 value and perform a upper case and lowercase method to the string. import
function method
function method  input Rs. 12000 Discount= 10%, 8% = Rs.(12000-1200) = Rs.(10800-864) = Rs. 9936
Advertisements
function method
function method  input Rs. 12000 Discount= 10%, 8% = Rs.(12000-1200) = Rs.(10800-864) = Rs. 9936
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
How i write a function/method in jsp?
How i write a function/method in jsp?  How write the function/method in jsp? Using that method i can retrieve the value coming from database. give me example plz. Actually i want to show the list of user detail
function
function  difference between function overloading and operator overloading
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?  How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js? I set
Flex Trace Method, Trace function in Flex
Function Trace function is used for debugging the application which prints... and terminate button stops the debugging session. Flex Trace Method Example... mx.controls.Alert; public function init():void{ trace("Init started
method
method   how and where, we can define methods ? can u explain me with full programme and using comments
method
method  can you tell me how to write an abstract method called ucapan() for B2 class class A2{ void hello(){ system.out.println("hello from A2"); }} class B2 extends A2{ void hello(){ system.out.println("hello from B2
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 written as <form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
JavaScript method eval()
JavaScript method eval()       This section illustrates you the use of JavaScript method eval(). This function evaluates the string passed into the method and executes it. Its syntax
PHP invoke Method
Method Example: <?php class A { public function __invoke($var){ var...__invoke() Function in PHP: PHP 5.3.0 has introduced so many new concepts, new functions. __invoke() is one of them. The functionality of __invoke() method
JPA Abs Function
JPA Abs Function       In this section, you will learn about the JPA Abs() function. This method returns absolute value of the given field. JPA Abs Function
JPA Sqrt Function
JPA Sqrt Function       In this section, you will learn about the JPA sqrt() function. This method returns the square root of the given argument. JPA sqrtFunction
JPA Avg Function
JPA Avg Function       In this section, you will learn the avg of aggregate function. This method calculate an average of  given data. JPA Avg() function
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
using function
using function   using a function to find the value of v from the foiiowing expression 1v=1u+1*f
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
JPA Locate Function
() function. This method returns the index of search string in specified string. String... JPA Locate Function     ...;. JPA locate Function: Query query= em.createQuery("SELECT
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
method name
method name  Is there any method which is equivalent to c++'s delay(int) function
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
Overload function in actionscript
Overload function in actionscript  Hi.... How do you overload...; public namespace method3; public function MethodOverloadingExample():void { method1::overloadedMethod(1); } method1 function overloadedMethod(a:int):void
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 and print that data.. don't want javascripts..  Writing Method in JSP
The strpos() function
The strpos() function The strpos() function is used to find the availability of a sub string/string inside a string. This function returns FALSE ,if the string or sub string provided is not found. The syntax of the above method
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
Tutorials   
Java Spring Hibernate Struts Training Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include?

Ads

 
Advertisement null

Ads