Hands on Testing Java: Lab #3

Homework Projects

Configure Your Project

  1. Create a file named Design/project03.txt.
  2. Create a new package in your project named edu.INSTITUTION.USERNAME.hotj.project03.
  3. Create the classes needed for the assigned project as part of the edu.INSTITUTION.USERNAME.hotj.project03 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 #3.1: Finish the lab exercise by completing the remaining experiments. If you are assigned this project, you do not have to create a new package for the project; just add to the code that you used in lab.

Project #3.2: Write a program that finds the resistance of an electronic circuit with three parallel resistors resistor1, resistor2, and resistor3. The resistance can be computed using the following formula:

 
                                   1
   resistance = --------------------------------------
                     1            1            1
                 ---------- + ---------- + ----------
                 resistor1    resistor2    resistor3

Project #3.3: The two solutions of a quadratic equation

y = ax2 + bx + c

can be found using the quadratic formula:

solution1 = -b + the square root of (b2 - 4ac)
            -----------------------------------
                           2a

and

solution2 = -b - the square root of (b2 - 4ac)
            -----------------------------------
                           2a

Write a program that inputs values for a, b and c, and outputs the values of solution1 and solution2. Use boolean expressions to print out true or false for these conditions:

Project #3.4: Write a program that, given the amount of a purchase and the amount received in payment, computes the change in dollars, half-dollars, quarters, dimes, nickels and pennies.

This grade sheet will be used to compute your grade.

Turn In

Turn the following things:

  1. Your source program.
  2. A sample execution from three executions of your executable program.

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