Lab Homework 4

You are to complete this homework before attending the fifth lab.

Solve chapter 4 exercise 16 (Quadrant, page 299). First solve it in PracticeIt. Then copy and paste the following code into jGRASP and copy your solution from PracticeIt into the program to complete it:

// This program prints results for the 7 test cases from the PracticeIt version
// of the Quadrant problem.  The output should be 1 2 3 4 0 0 0.

public class QuadrantTest {
   public static void main(String[] args) {
      System.out.println(quadrant(12.4, 17.8));
      System.out.println(quadrant(-2.3, 3.5));
      System.out.println(quadrant(-15.2, -3.1));
      System.out.println(quadrant(4.5, -4.5));
      System.out.println(quadrant(0.0, 0.0));
      System.out.println(quadrant(12.5, 0.0));
      System.out.println(quadrant(0.0, 2.3));
   }

   // include your solution to the quadrant method here
}

Working on this problem will help prepare you for the homework assignment. Remember that for these warm-up exercises you can talk to each other about how to solve it and even look at each other's solutions. Then you should work on the weekly programming assignment by yourself.