Can you help me with this project please can't do it.
For this project you are required to write a program which takes a sentence(i.e. string) as input, and prints out various statistics about the sentence. Sample output for the program will be shown below.
The first fir$t SP Project sp!
The Number of Valid Words 4
The Longest Word Project
The Shortest Word SP
The words counted by the program should only be valid words i.e. only those containing alphabetic characters.
Look at the Scanner class in the API (java.util.Scanner), use to read in each word of the String. That is a start, then you will need to write methods to count the letters etc.
Joined: Jan 21, 2009
Larry Frissell wrote:Look at the Scanner class in the API (java.util.Scanner), use to read in each word of the String. That is a start, then you will need to write methods to count the letters etc.
Can you write out the program for me please I am new to this.
Joined: May 16, 2008
At JavaRanch the motto is "Do your Homework" and "We are not a code mill", see this. Try to take the first step, using the Scanner class to get your string input, insert the words in the array of your choice. If you have problems post the code you have and others will help guide you.
Do you know how to write, compile and run a java program? That is the first step. Assuming you can do that, write this one in teeny tiny steps. My first go at it would do nothing more than prompt for the input - I.e. print the "Input Sentence:".
once you have it doing that, see if you can actually take in the input.
Once you do that, see if you can figure out how to find the individual words.
Once you do that, try and find the longest word
Note that at each step, you may have to write some extra code to prove what you did works, and then throw that away later. Once you think you have read in the input, you may want to print it out again to verify you REALLY have captured it. Once you KNOW that works, you can remove the echoing out the input.
If you tackle a problem like this in baby step, it's much easier.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors