// CSE 142, Autumn 2009, Marty Stepp // This program was used to write our 'quadrant' method in lecture. // The main purpose of the program was to practice writing a method // that uses if/else with return, and to practice a problem that is // similar to a programming question that would appear on an exam. import java.util.*; public class Quadrants { public static void main(String[] args) { int quad = quadrant(-4.2, 17.3); System.out.println("The quadrant is: " + quad); } public static int quadrant(double x, double y) { if (x > 0 && y > 0) { return 1; } else if (x < 0 && y > 0) { return 2; } else if (x < 0 && y < 0) { return 3; } else if (x > 0 && y < 0) { return 4; } else { return 0; } } }