wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes java project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java project" Watch "java project" New topic
Author

java project

john teevan
Greenhorn

Joined: Jan 21, 2009
Posts: 2
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.

Example

Input sentence:

The first fir$t SP Project sp!


Sentence Statistics

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.

Larry Frissell
Ranch Hand

Joined: May 16, 2008
Posts: 82
    
    2
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.
john teevan
Greenhorn

Joined: Jan 21, 2009
Posts: 2
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.
Larry Frissell
Ranch Hand

Joined: May 16, 2008
Posts: 82
    
    2
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.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11229
    
  16

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

etc.

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java project