Input a sentence and a word. Print the output after excluding that word from the sentence (if found). A variable description table is to be written. Sample Input: Rahul has worked very hard. His performance is very good. Keyword: very
Answers
Yeah i want it too pls give
Explanation:
Explanation:
import java.util.Scanner;
public class abc
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a sentence:");
String str = in.nextLine();
str = str + " ";
String word = "", mWord = "";
int count = 0, maxCount = 0;
int len = str.length();
for (int i = 0; i < len; i++)
{
char ch = Character.toUpperCase(str.charAt(i));
if (ch == 'V' ||
ch == 'E' ||
ch == 'R' ||
ch == 'Y' ||
{
count++;
}
if (ch == ' ') {
if (count > maxCount) {
maxCount = count;
mWord = word;
}
word = "";
count = 0;
}
else {
word += ch;
}
}
System.out.println("The word count of verb word is : "
+ mWord);
}
}