Important Notice:

Practice-It will be discontinued as of November 1st, 2024. After this date, the website will remain online for a transitional period, but login will be restricted to University of Washington NetID authentication. This marks the next phase towards the platform's full retirement. Thank you for your use and support of the application over the years.

If you are looking for an alternative, a similar tool, CodeStepByStep, was developed independently by the original author of Practice-It, and is available at codestepbystep.com**

logo Practice-It logo

BJP4 Exercise 5.16: anglePairs

Language/Type: Java if/else method basics return
Author: Marty Stepp (on 2016/09/08)

Write a static method named anglePairs that accepts three angles (integers), measured in degrees, as parameters and returns whether or not there exists both complementary and supplementary angles amongst the three angles passed. Two angles are complementary if their sum is exactly 90 degrees; two angles are supplementary if their sum is exactly 180 degrees. Therefore, the method should return true if any two of the three angles add up to 90 degrees and also any two of the three angles add up to 180 degrees; otherwise the method should return false. You may assume that each angle passed is non-negative.

Here are some example calls to the method and their resulting return values.

Call Value Returned
anglePairs(0, 90, 180)
anglePairs(45, 135, 45)
anglePairs(177, 87, 3)
anglePairs(120, 60, 30)
anglePairs(35, 60, 30)
anglePairs(120, 60, 45)
anglePairs(45, 90, 45)
anglePairs(180, 45, 45)
true
true
true
true
false
false
false
false
Type your solution here:


This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.