import [Link].
*;
class StartsEnds {
public static void main(String args[]) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a string:");
String s = [Link]();
[Link]("Starts with 'A'? " + [Link]("A"));
[Link]("Ends with 'Z'? " + [Link]("Z"));
}
}
import [Link].*;
class CompareWords {
public static void main(String args[]) {
Scanner sc = new Scanner([Link]);
[Link]("Enter first word:");
String w1 = [Link]();
[Link]("Enter second word:");
String w2 = [Link]();
int res = [Link](w2);
if (res == 0)
[Link]("Both words are equal.");
else if (res < 0)
[Link](w1 + " comes before " + w2);
else
[Link](w1 + " comes after " + w2);
}
}
import [Link].*;
class LongestWord {
public static void main(String args[]) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence:");
String s = [Link]() + " ";
String word = "", maxWord = "";
for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if (ch != ' ')
word += ch;
else {
if ([Link]() > [Link]())
maxWord = word;
word = "";
}
}
[Link]("Longest word: " + maxWord);
}
}
import [Link].*;
class PalindromeWords {
public static void main(String args[]) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence:");
String s = [Link]() + " ";
String word = "";
[Link]("Palindrome words:");
for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if (ch != ' ')
word += ch;
else {
String rev = "";
for (int j = [Link]() - 1; j >= 0; j--)
rev += [Link](j);
if ([Link](rev))
[Link](word);
word = "";
}
}
}
}
import [Link].*;
class ReverseWords {
public static void main(String args[]) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence:");
String s = [Link]() + " ";
String word = "", result = "";
for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if (ch != ' ')
word += ch;
else {
result = word + " " + result;
word = "";
}
}
[Link]("Reversed Sentence: " + [Link]());
}
}
import [Link].*;
class MostVowelWord {
public static void main(String args[]) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence:");
String s = [Link]() + " ";
s = [Link]();
String word = "", maxWord = "";
int vowelCount = 0, maxVowel = 0;
for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if (ch != ' ') {
word += ch;
if ("AEIOU".indexOf(ch) != -1)
vowelCount++;
} else {
if (vowelCount > maxVowel) {
maxVowel = vowelCount;
maxWord = word;
}
word = "";
vowelCount = 0;
}
}
[Link]("Word with most vowels: " + maxWord);
}
}
import [Link].*;
class LongestWord {
public static void main(String args[]) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence:");
String s = [Link]() + " ";
String word = "", maxWord = "";
for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if (ch != ' ')
word += ch;
else {
if ([Link]() > [Link]())
maxWord = word;
word = "";
}
}
[Link]("Longest word: " + maxWord);
}
}