Write a public method called containsDivPair that:
• accepts three integer parameters
• returns true if any two of the numbers are divisible by 5, false otherwise
public static boolean containsDivPair(int n1, int n2, int n3) { return n1 % 5 == 0 && n2 % 5 == 0 || n1 % 5 == 0 && n3 % 5 == 0 || n2 % 5 == 0 && n3 % 5 == 0; }
public class DivPair { public static boolean containsDivPair(int n1, int n2, int n3) { return n1 % 5 == 0 && n2 % 5 == 0 || n1 % 5 == 0 && n3 % 5 == 0 || n2 % 5 == 0 && n3 % 5 == 0; } public static void main(String[] args) { System.out.println(containsDivPair(5, 10, 15)); System.out.println(containsDivPair(5, 12, 15)); System.out.println(containsDivPair(5, 10, 11)); System.out.println(containsDivPair(5, 12, 17)); } }
Get Answers For Free
Most questions answered within 1 hours.