• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java project

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 82
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 82
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic