Java Programming

Don't know how to start..
Can anyone help me?


For this program you are to create a two class application - a driver and a principal class - that reads in text interactively from the keyboard, and then reports on two aspects of the entered text. First it should print a table of word sizes in the entered text, for sizes from 1 up to 12 and larger; and second, it should report the number of sentences in the text. To be clear on how this should work, here is the text from a sample run:

> run WordProfileDriver
Enter lines of text, type two returns in a row to end

[DrJava Input Box] The time has come, the walrus said - to speak of many things
[DrJava Input Box] At least that's how the ultra-ultra-famous first line goes, from the
[DrJava Input Box]the Lewis Carroll poem! If you don't know it, give it a try.

words of size 1---2
words of size 2---6
words of size 3---9
words of size 4---10
words of size 5---5
words of size 6---3
words of size 7---1
words of size 8---0
words of size 9---0
words of size 10---0
words of size 11---0
words of size >= 12---1
sentences: 2

As you can see, the driver class is called WordProfileDriver (you must use this name). The second class, where all the action happens, must be called WordProfile. Some further thoughts:



Read input using the style of program Backwards from section 7.2 of the iJava textbook.


You must make essential use of arrays in your word size accounting. Notice that words that are of size 12 or larger are lumped together.


You will need to use a StringTokenizer for this problem. In addition to "space", these characters should be considered delimiters: ,.?!:; This means that dash - the symbol "-", and single quote - the symbol " ' ", should be considered characters in a word (and thus "can't" is a single word of length 5, a lone dash is actually a word of size 1, and "head-long" is a single word of length 9).


To count sentences, just count the number of ? (question mark), !(exclamation mark), .(period). Just counting these three sentence terminators is fairly easy, although strictly speaking it's not completely correct, since a sentence might end in ??, for example.


Lines should be read in in the driver, but should be processed using StringTokenizer in WordProfile. Also, the essential array, where where you keep track of word size counts, MUST be in the WordProfile class, and not in the driver.


When you paste in your code, do NOT paste in any import statements. We will import java.util for you, for both classes.



Put your WordProfile class here:

  1. 👍 0
  2. 👎 0
  3. 👁 173
asked by Sally
  1. From what I see in the specifications, it is likely that it is not your first Java course. If you really don't know where to start, you need a good revision before you even start.

    Having said that, here are some hints.

    1. main
    Since you "run WordProfileDriver", you will have your "main" method in the file WordProfileDriver.java which instantiates the WordProfile class, and does the screen IO to store the user input data into a String of the WordProfile object.

    2. WordProfile class

    It will have a String as an instance variable, constructor and get/set methods.
    You will likely to have an append method since input is read in in separate lines. Alternatively you can join the different lines in the main, but that's messy.
    You will need also an "analyse" method to do the calculations. This can be done only when the whole text has been entered, since sentences could be cut between lines.

    The StringTokenizer is an older class that helps in separating a text into "tokens" according to your definition of separators. You could use one set of separators for the words, and another for the sentences, basically run through the text twice. However, this is not a good practice for huge texts of several gigabytes. The approach depends on your level of techniques, namely simplicity versus performance.

    Work on the skeleton, and report back if you need further help.

    Note: do not start a new thread for the same problem in order to provide other teachers and other readers continuity.

    1. 👍 0
    2. 👎 0

Respond to this Question

First Name

Your Response

Similar Questions

  1. computers

    I have just started a basic class in programming and I am totally lost. Can someone help me out? I have to write pseudocodes and create flowchart and don't have a clue. I need help with the following: flowchart, pseudo-code, Input

    asked by Shawn on April 30, 2010
  2. Computer (Programming Logic and Design)

    How do i Create a program that determine the shipping cost for an order based on the following table: From To Price $0.00 $19.00 $2.95 $20.00 $49.99 $3.95 $50.00 $74.99 $4.95 $75.00 $1000.00 $Free I don't understand how to do

    asked by Derek Smith on December 2, 2012
  3. programming

    How do i Create a program that determine the shipping cost for an order based on the following table: From To Price $0.00 $19.00 $2.95 $20.00 $49.99 $3.95 $50.00 $74.99 $4.95 $75.00 $1000.00 $Free I don't understand how to do

    asked by Derek Smith on December 2, 2012
  4. computer programing

    okay I need a little help here on next program this what it say for first one which I have done. Create a counting program that counts backward from 100 to 1 in increments of 10. #include < stdio.h > int main () { Int i; while ( I

    asked by Poohboi on February 4, 2016
  5. C programming

    The task is to create a c source code program that will name a quadrant when a given coordinate is given. Example: Input Coordinate Pair: 0 5.3 Positive y Axis I just need help on how to start this. I know I have to use if else

    asked by Z32 on September 23, 2009
  6. Programming (CSI Programming Logic and Design)

    Create a program that outputs a letter grade for a student based on the following table: From To Grade 90 100 A 80 89 B 70 79 C 0 69 F I don't understand how to do this. Would you mind helping me get the answer to this Program?

    asked by Derek Smith on December 2, 2012
  7. Computer Science (Programming Logic And Design)

    Create a program that outputs a letter grade for a student based on the following table: From To Grade 90 100 A 80 89 B 70 79 C 0 69 F I don't understand how to do this. Would you mind helping me get the answer to this Program?

    asked by Derek Smith on December 2, 2012
  8. Programming (CSI 150 Programming Logic and Design)

    Create a program that outputs a letter grade for a student based on the following table: From To Grade 90 100 A 80 89 B 70 79 C 0 69 F I don't understand how to do this. Would you mind helping me get the answer to this Program?

    asked by Derek Smith on December 2, 2012
  9. Computer Science (Programming Logic And Design)

    Create a program that outputs a letter grade for a student based on the following table: From To Grade 90 100 A 80 89 B 70 79 C 0 69 F I don't understand how to do this. Would you mind helping me get the answer to this Program?

    asked by Derek Smith on December 2, 2012
  10. Diversity in the Classroom

    Create an At-Risk Program. What would be At-Risk Program that I can create? I need to talk about how the at-risk population will have an affect on the program serve.

    asked by B.B. on May 17, 2009
  11. Programming logic and design

    Using python write a program that does the following: •Create the logic for a program that calculates and displays the amount of money you would have if you invested $3000 at 2.65 percent interest for one year. •Create a

    asked by Christina on April 17, 2015

More Similar Questions