Hands on Testing Java: Lab #10

Homework Projects

Configure Your Project

  1. Create a file named Design/project10.txt.
  2. Create a new package in your project named edu.INSTITUTION.USERNAME.hotj.project10.
  3. Create the classes needed for the assigned project as part of the edu.INSTITUTION.USERNAME.hotj.project10 package.

The Projects

Your instructor will assign you one of the problems below. To solve your problem, write a program that reads the necessary information to compute and output the indicated values, as efficiently as possible. Following the pattern in the lab exercise, first, design using OCD. Then code your design in Java using stepwise translation. Test your program thoroughly.

When executing your program to hand in as part of the project, a JUnit test case should test each method at least five times, but the test case itself needs to be executed just once. A driver program should be run at least five times with different inputs each time.

Project #10.1: Write a program that reads from a file of real numbers, and displays the minimum, maximum, average, and range of the numbers in the file. The user should be able to enter the name of the input file from the keyboard.

Project #10.2: Write a program that reads the contents of a file and creates an exact copy of the file, except that each line is numbered. For example, if the input file contains the following text:

'Twas brillig, and the slithy toves
   Did gyre and gimble in the wabe;
All mimsy were the borogoves,
  And the mome raths outgrabe.
                      - Lewis Carroll

Then the output file should appear something like this:

1: 'Twas brillig, and the slithy toves
2:    Did gyre and gimble in the wabe;
3: All mimsy were the borogoves,
4:    And the mome raths outgrabe.
5:                         - Lewis Carroll

The user should specify the names of the input and output files in command-line arguments.

Project #10.3: Write a text-analysis program that reads an essay or composition stored in a text file, and determines the number of words, the number of sentences, the average number of words per sentence, the average number of letters per word, and a complexity rating, using:

complexity = 0.5 * averageSentenceLength + 0.5 * averageWordLength.

Based on these calculations, your program should assess the writing level of the essay as:

The user should supply the name of a file in command-line argument.

Turn In

Turn the following things:

  1. This grade sheet
  2. An OCD design for one of your methods.
  3. All source files you created for your project.
  4. A change log for your code files.
  5. Sample executions of your test cases and drivers (as applicable).

Lab Home Page | Prelab Questions | Lab Exercise | Homework Projects