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



Home Answers Viewqa JSF-Questions do the following
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


mayur patel
do the following
7 Answer(s)      a year and 8 months ago
Posted in : Java Server Faces Questions


write a program to enter the string and do the following 1- count totle number of vowel 2- replace vowel 3- delete the charactor from given value 4- riverce the string 5- convert second word in upercase 6- convert third word in lowercase


Advertisement
View Answers

June 12, 2013 at 4:48 PM


hi friend,

Try the following code, may this will be helpful for you

index.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">
<head>
<title>Index Page Example</title>
</head>
<body>
<table>
<tr>
<td><h:link value="Get No Of Vowels" outcome="vowel" /></td>
</tr>
<tr>
<td><h:link value="Get Reverse String" outcome="reverse" /></td>
</tr>
<tr>
<td><h:link value="Change Character In Upper Case" outcome="upperText" /></td>
</tr>
<tr>
<td><h:link value="Change Character In Lower Case" outcome="lowerText" /></td>
</tr>
<tr>
<td><h:link value="Delete Character" outcome="delete" /></td>
</tr>
</table>
</body>
</html>

Continue...



June 12, 2013 at 4:49 PM


vowel.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Count Vowel Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter String To Check Vowel : </td>
<td><h:inputText id="nameText" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15" accesskey="t"/></td>
<td><h:message for="nameText" style="color:red" /></td>
</tr>
<tr>
<td>Total No Of Vowels Are : </td>
<td><h:outputText value="#{vowel.count}"/></td>
</tr>
<tr>
<td><h:commandButton value="Get Vowel Count" action="#{vowel.getVowel(vowel.str)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...



June 12, 2013 at 4:50 PM


reverse.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Reverse String Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter A String To Reverse : </td>
<td><h:inputText id="text1" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15"/></td>
<td><h:message for="text1" style="color:red" /></td>
</tr>
<tr>
<td>New String After Reverse : </td>
<td><h:outputText value="#{vowel.revString}"/></td>
</tr>
<tr>
<td><h:commandButton value="Reverse Value" action="#{vowel.reverseString(vowel.str)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...



June 12, 2013 at 4:52 PM


upperText.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Upper Text Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter A String To Convert In Upper Case 
<table>
<tr>
<td>(Second Word Should Be In Lower Case)</td>
</tr>
</table>
</td>
<td><h:inputText id="text1" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15"/></td>
<td><h:message for="text1" style="color:red" /></td>
</tr>
<tr>
<td>New String In Upper Case : </td>
<td><h:outputText value="#{vowel.strUpper}"/></td>
</tr>
<tr>
<td><h:commandButton value="Get Upper" action="#{vowel.upper(vowel.str)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...



June 12, 2013 at 4:58 PM


lowerText.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Lower Text Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter A String To Convert In Lower Case 
<table>
<tr>
<td>(Third Word Should Be In Upper Case)</td>
</tr>
</table>
</td>
<td><h:inputText id="text1" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15"/></td>
<td><h:message for="text1" style="color:red" /></td>
</tr>
<tr>
<td>New String In Lower Case : </td>
<td><h:outputText value="#{vowel.strLower}"/></td>
</tr>
<tr>
<td><h:commandButton value="Get Lower" action="#{vowel.lower(vowel.str)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...



June 12, 2013 at 5:00 PM


delete.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<title>Delete Character Example</title>
</h:head>
<h:body>
<h1>JSF Example</h1>
<h:form id="form1">
<table>
<tr>
<td>Enter A String : </td>
<td><h:inputText id="text2" value="#{vowel.str}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15"/></td>
<td><h:message for="text2" style="color:red" /></td>
</tr>
<tr>
<td>Enter Character To Delete : </td>
<td><h:inputText id="text1" value="#{vowel.ch1}" required="true" requiredMessage="Field Mustn't Be Empty" tabindex="5" maxlength="15" accesskey="c"/></td>
<td><h:message for="text1" style="color:red" /></td>
</tr>
<tr>
<td>New String After Delete</td>
<td><h:outputText value="#{vowel.str1}"/></td>
</tr>
<tr>
<td><h:commandButton value="Delete Character" action="#{vowel.deleteChar(vowel.ch1)}" /></td>
</tr>
</table>
</h:form>
</h:body>
</html>

Continue...



June 12, 2013 at 5:01 PM


FindVowel.java

package devmanuals;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name="vowel")
@RequestScoped
public class FindVowel {

    String str, str1, revString="", strUpper="", strLower="";

    int count=0;
    char ch;
    char ch1, ch2;

    public String getStrLower() {
        return strLower;
    }

    public String getStrUpper() {
        return strUpper;
    }

    public String getRevString() {
        return revString;
    }

    public String getStr() {
        return str;
    }

    public void setStr(String str) {
        this.str = str;
    }

    public int getCount()
    {
        return count;
    }

    public String getStr1()
    {
        return str1;
    }

    public char getCh1() {
        return ch1;
    }

    public void setCh1(char ch1) {
        this.ch1 = ch1;
    }

    public void lower(String str2)
    {
        //String newString="";
        StringBuffer sb = new StringBuffer();
        for(int i=0; i < str2.length(); i++)
        {
            //System.out.println(i+" "+str2.charAt(i));
            //str2.charAt(i);
            if(i < 2)
            {
            sb.append(str2.charAt(i));
            }
            if(i==2)
            {
                char c = str2.charAt(i);
                String u = Character.toString(c);
                sb.append(u.toLowerCase());             
            }
            if(i > 2)
            {
                sb.append(str2.charAt(i));
            }
        }
        strLower = sb.toString();       
    }   

    public void upper(String str2)
    {
        //String newString="";
        StringBuffer sb = new StringBuffer();
        for(int i=0; i < str2.length(); i++)
        {
            //System.out.println(i+" "+str2.charAt(i));
            //str2.charAt(i);
            if(i < 1)
            {
            sb.append(str2.charAt(i));
            }
            if(i==1)
            {
                char c = str2.charAt(i);
                String u = Character.toString(c);
                sb.append(u.toUpperCase());             
            }
            if(i > 1)
            {
                sb.append(str2.charAt(i));
            }
        }
        strUpper = sb.toString();       
    }

    public void reverseString(String str2)
    {       
        for(int i=str2.length()-1; i >= 0; i--)
        {
            revString = revString+str2.charAt(i);           
        }       
    }

    public void deleteChar(char c)
    {
        if(c != 0)
        {
            for(int i=0; i< str.length(); i++)
            {
                ch2 = str.charAt(i);
                if(c == ch2)
                {
                    str1 = str.replace(""+c, "");
                }
            }
        }       
    }

    public void getVowel(String text)
    {       
        if(text != null)
        {                   
            for(int i = 0; i< text.length(); i++)
            {
                ch = text.charAt(i);
                if(ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' ||
                    ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U')
                {
                    count++;
                }
            }       
        }
    }   
}

Thanks.



Related Tutorials/Questions & Answers:
do the following
do the following  write a program to enter the string and do the following 1- count totle number of vowel 2- replace vowel 3- delete the charactor from given value 4- riverce the string 5- convert second word in upercase 6
Write a program named InternetCharge_YourLastName that do the following:
Write a program named InternetCharge_YourLastName that do the following: ..._YourLastName that do the following: *display the menu as follow: 1. Package A 2... the total charge in the following format. The total charge will include the tax 8.5
Advertisements
The while and do
While and do-while      ... a particular condition is true. To write a while statement use the following form... that the condition becomes false and the loop terminates. Have a look at do
how to do this?
how to do this?   Given any integer 2D array, design then implement a Java program that will add to each element in the array the corresponding... and after modification. For example, if the program fed with following 2D array
source code for the following question
source code for the following question  source code for the fuzzy c-means
Print the following format
Print the following format  how to print the following format given string "00401121" in java 0-** 1-* 2-* 3- 4
Expain the following code ?
Expain the following code ?  please explain the following line of code clearly? <html:link href="user.do?parameter=create">Create User</html:link>
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6
covert the following using java
covert the following using java  how to convert (for eg : 2.89) . this decimal to binary in java
write following program
write following program  Q1 What is the difference between single threaded application and multithreaded application? What are the benefits of multi... between applet and HTML? Q13 How do you add a class or an interface to a package
print the following series
print the following series  a b c d e b c d e c d e d e e   Hi Friend, Try the following code: class StringPattern { public static void main(String[] args) { String st="abcde
print array in following format
print array in following format  i want print two array in following format first array= 1,2,3,4,5,6,7,8,9 second array=11,12,13,14,15,16,17,18,19 i...; Here is a code that displays the array values in the following pattern: 1 2
C program to print the following
C program to print the following  Hello, Some one help me with a "C Program" to print the following as output: 4444444 4333334 4322234 4321234 4322234 4333334 4444444 // for input 4. And also
how to print the following pattern
how to print the following pattern  Hello hEllo heLlo helLo hellO pls reply soon its an emergency   class StringPattern { public static void main(String[] args) { String st="hello
do-while loop
do-while loop  how many times will the following loop get executed and what will be the final value of the variable I after execution the loop is over. int I = 5; do{ I + = 3; System.out.println(""+I); I=I+1; }while(I>=9
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
Java errors when attempting the following.
Java errors when attempting the following.  Give the java errors in attempting the following : 1) performing division operation on string value. 2) redefining base class final method in derived class. 3) defining a method
How to print the following pattern in java?
How to print the following pattern in java?  How to print the following pattern in java? he he is he is going he is going in   import java.io.*; class StringPattern { public static void main(String[] args
Need the Following MobileApplication Related Code
Need the Following MobileApplication Related Code  Hi, I need java coding for the following requirements in Collections.. Mobile Subscriber name: Subscriber PhonNo: Add the Subscriber: Update the Subscriber
Please provide coding for following problem
Please provide coding for following problem  Please provide the coding for the following problem: You will write a java program that will read data from a file. The data in the file will be: John Doe 75 Joe Blow 65 Mary Smith 80
Use of "following" in XPath
Use of "following" in XPath   ... will select each and every node or element following this current node closing...;XPathFactory.newInstance().newXPath(); Expression "//person/following
php do while loop
php do while loop  Difference between do while loop and simple loop in PHP
php do while example
php do while example  Simple example of do while loop in PHP
php do while syntax
php do while syntax  How to create a do while loop in php. What is the syntax
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
php do while false
php do while false   Is there any difference between FALSE and false
while and do while
while and do while  hello, What is the difference between a while statement and a do statement?   hello, A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do
How to do url rewritting?
How to do url rewritting?  Dear Sir/Mam I have this link http://localhost:8085/call4admission/admin/home/Admin... to do?Please suggest
What does COMMIT do?
What does COMMIT do?  What does COMMIT do?   Hi, here is the answer, COMMIT makes permanent the changes made by DML statements in the transaction. The changes made by the DML statements of a transaction become
Advertisements
 

 

 

DMCA.com