Skip to main content

Find number of characters in Longest word - Java Program

This java program finds the longest word in a string inputted by the user and prints the number of characters of that word.

Q. Write a program to input a sentence and print the number of characters found in the longest word of the given sentence. For example, if sentence is " India is my country", then the output should be 7.

Comments

Popular posts from this blog

Shifting Agriculture

  What is Shifting agriculture? Shifting Agriculture also known as 'Slash-and-Burn' method is a very common practice of cultivation prevalence in countries such as India. In this method, farmers make a small clearing in the forest where the cultivation of crops is done solely dependent on monsoon rain for irrigation and natural fertility of soil. No artificial input of either irrigation or fertilizer is given by the farmer. This method is very harmful to the environment. Shifting agriculture  Key features of Shifting agriculture:  Following are the key features of shifting agriculture: It is practiced on small patches of land with the help of primitive tools. It is also called jhumming , agriculture where the farmers make a small clearing in the forest, cultivate it for some years and then abandon it when the fertility of the soil diminishes. They then shift to another fresh clearing in the forest. This is also called slash-and-burn agriculture. The patch of land is usu...

Abou Ben Adhem

  Abou Ben Adhem                                           by-   Leigh Hunt Abou Ben Adhem (may his tribe increase) Awoke one night from a deep dream of peace, And saw, within the moonlight in his room, Making it rich, and like a lily in bloom, An Angel writing in a book of gold:- Exceeding peace had made Ben Adhem bold, And to the presence in the room he said, "What writest thou?" - The vision raised it's head, And with a look made of of all sweet accord, Answered, "The names of those who love the Lord." " And is mine one?" said Abou. "Nay, not so," Replied the angel. Abou spoke more low, But cheeringly still; and said, " I pray thee, then, Write me as one that loves his fellow men." The Angel wrote, and vanished. The next night It came again with ...

Simple Java Programs (Part 1)

 Q. Define a class to declare a character array of size ten, accept the character into the array and perform the following:  • Count the number of uppercase letters in the array and print.  • Count the number of vowels in the array and print. Q. Define a class to declare an array of size 20 of double datatype, accept the elements into the array and perform the following:  • Calculate and print the sum of all the elements.  • Calculate and print the highest value of the array. Q. Define a class to accept two strings, convert them into uppercase, check and display whether two strings are equal or not, if the two strings are not equal, print the string with the highest length or print the message both the strings are of equal length. Q. Define a class to accept a string, convert it into lowercase and check whether the string is a palindrome or not.  A palindrome is a word which reads the same backward as forward.  Example:  madam, racecar etc...