Answer:
The java program for the scenario is given below.
import java.util.*;
public class Test
{
// method returning sum of all digits in the integer parameter
static boolean anglePairs(int a1, int a2, int a3)
{
// variable to hold sum of two complementary angles
int comp=90;
// variable to hold sum of two supplementary angles
int supp=180;
// boolean variable to hold result
boolean result = false;
if( (a1+a2 == comp) || (a2+a3 == comp) || (a1+a3 == comp) )
{
if( (a1+a2 == supp) || (a2+a3 == supp) || (a1+a3 == supp) )
result = true;
else
result = false;
}
// return variable result
return result;
}
public static void main(String[] args)
{
// method is called by passing three positive angles
System.out.println("The pair of angles have both complementary and supplementary angles " + anglePairs(100, 80, 90) );
}
}
OUTPUT
The pair of angles have both complementary and supplementary angles false
Explanation:
The program works as described below.
1. The method, anglePairs(), is declared as static having return type as Boolean which takes three positive integer parameters.
static boolean anglePairs(int a1, int a2, int a3)
{
}
2. The integer variable, comp, is declared and initialized to 90.
3. The integer variable, supp, is declared and initialized to 180.
4. The Boolean variable, result, is declared and initialized to false.
5. Using if-else statements, sum of two angles are compared with the variables, comp and supp.
6. If the sum of any two angles match with both, comp and supp, variables, the Boolean variable, result is assigned value true. Otherwise, result is assigned value false.
7. The value of result is returned.
8. Inside main() method, the function anglePairs() is called and three positive numerical values are passed as parameters. The output is displayed.
9. All the above code is written inside the class Test.
10. User input is not taken since it is not mentioned in the question.