Discussion topic: Contributed Answer/Explanation to Q. 1
To go to the homepage of this topic,
click here.
Home: arpit159 | Original Message | Reply | Subject: Contributed Answer/Explanation to Q. 2 |
class string operation
{
public static void main(String args[])
{
String w=""; // null string
System.out.println ("Enter a String");
String str=br.readLine (); //user input string.
int l=str.length();
int wl=checkvowel=checkcharecter=0; // initial zero
System.out.println("Sentence No. of Vowels No. of Words");
// output outline
for(i=0;i=l;i++)
{
char z=str.charAt (i);
w=w+z; //picking each latter (character) and adding it to form
a word.
if(z=='!'||z=='.'||z=='?')
{
wl=w.length();
/*
length of the word, which is form by adding each character
*/
for(int j=0;j=(wl-1);j++)
/*
j=(wl-1), because last character of the word w will be a special character
(i.e. '!' , '.', '?') which is not need to be counted
*/
{
char x=w.chatAt (j); //extraction of character from word
if(x=='A'||x=='a'||x=='E'||x=='e'||x=='I'||x==i||x=='O'||x=='o'||x=='u'||x==
'U')
{ //checking vowels.
checkvowel++; //if vowel found in a word w, checkvowel value add up one.
checkcharecter++;
}
checkcharecter++; //character present in the word is counted
} //closing of word loop
} //closing of finishing of word loop when encountered '!', '?', '.'
System.out.println( checkvowel+" "+checkcharecter);
w=""; //assigning null to word w, so it can form new word again
} //closing of for loop
} //closing of main
}//closing of class
Posted at: Fri Feb 8 20:44:47 2013 (GMT) |
Page 1 of 1 | From: arpit159 | Reply 1 of 1 | Reply | | Subject: Contributed Answer/Explanation to Q. 2 |
class string operation
{
public static void main(String args[])
{
String w=""; // null string
System.out.println ("Enter a String");
String str=br.readLine (); //user input string.
int l=str.length();
int wl=checkvowel=checkcharecter=0; // initial zero
System.out.println("Sentence No. of Vowels No. of Words");
// output outline
for(i=0;i=l;i++)
{
char z=str.charAt (i);
w=w+z; //picking each latter (character) and adding it to form
a word.
if(z=='!'||z=='.'||z=='?')
{
wl=w.length();
/*
length of the word, which is form by adding each character
*/
for(int j=0;j=(wl-1);j++)
/*
j=(wl-1), because last character of the word w will be a special character
(i.e. '!' , '.', '?') which is not need to be counted
*/
{
char x=w.chatAt (j); //extraction of character from word
if(x=='A'||x=='a'||x=='E'||x=='e'||x=='I'||x==i||x=='O'||x=='o'||x=='u'||x==
'U')
{ //checking vowels.
checkvowel++; //if vowel found in a word w, checkvowel value add up one.
checkcharecter++;
}
checkcharecter++; //character present in the word is counted
} //closing of word loop
} //closing of finishing of word loop when encountered '!', '?', '.'
System.out.println( checkvowel+" "+checkcharecter);
w=""; //assigning null to word w, so it can form new word again
} //closing of for loop
} //closing of main
}//closing of class
Posted at: Fri Feb 8 20:46:55 2013 (GMT)
|
Page 1 of 1
|
|
To post to this forum, you must be signed in as a Syvum member.
Please sign in / register as a member.