Programming Write a Static Method Named ContainsBothDigits That Accepts Three
Question 5
Question 5
Essay
Programming Write a static method named containsBothDigits that accepts three integer parameters a, b, and c. Assume that a is a positive integer (greater than 0) and that b and c are single-digit numbers from 0-9 inclusive. Your method should return true if a contains both b and c at among its digits, and false otherwise. For example, the number 433407 contains 4, 3, 0, and 7 as its unique digit values, so a call to your method of containsBothDigits(433407, 7, 3) should return true. If b and c are the same number, your method should return true if that digit appears at least once among the digits; in other words, the same digit from a could match both b and c. So for example, a call of containsBothDigits(433407, 7, 7) should return true. Note that the digit b or c might appear more than once in a, as with 433407 containing two 3s. The following table lists some additional calls to your method and their expected return values: Call containsBothDigits (12345,2,5) containsBothDigits (3004955,3,0) containsBothDigits (1650,6,6) containsBothDigits (12198,1,7) containsBothDigits (42,9,2) containsBothDigits (904487,2,6) containsBothDigits (8,2,3) Value Returned true true true false false false false Reason 12345 contains the digits 2 and 53004955 contains the digits 3 and 01650 contains the digit 612198 does not contain the digit 742 does not contain the digit 9904487 does not contain the digit 2 or 68 does not contain the digit 2 or 3 Note: You may not use a String to solve this problem.
Correct Answer:
Verified
public static boolean containsBothDigits...
View Answer
Unlock this answer now Get Access to more Verified Answers free of charge