Examlex

Solved

Programming
Write a Static Method Named ContainsBothDigits That Accepts Three

question 6

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  Value Returned  Reason  containsBothDigits (12345,2,5) true 12345 contains the digits 2 and 5 containsBothDigits (3004955,3,0) true 3004955 contains the digits 3 and 0 containsBothDigits (1650,6,6) true 1650 contains the digit 6 containsBothDigits (12198,1,7) false 12198 does not contain the digit 7 containsBothDigits (42,9,2) false 42 does not contain the digit 9 containsBothDigits (904487,2,6) false 904487 does not contain the digit 2 or 6 containsBothDigits (8,2,3) false 8 does not contain the digit 2 or 3\begin{array}{l|l|l}\hline \text { Call } & \text { Value Returned } & \text { Reason } \\\hline \text { containsBothDigits }(12345,2,5) & \text { true } & 12345 \text { contains the digits } 2 \text { and } 5 \\\hline \text { containsBothDigits }(3004955,3,0) & \text { true } & 3004955 \text { contains the digits } 3 \text { and } 0 \\\hline \text { containsBothDigits }(1650,6,6) & \text { true } & 1650 \text { contains the digit } 6 \\\hline \text { containsBothDigits }(12198,1,7) & \text { false } & 12198 \text { does not contain the digit } 7 \\\hline \text { containsBothDigits }(42,9,2) & \text { false } & 42 \text { does not contain the digit } 9 \\\hline \text { containsBothDigits }(904487,2,6) & \text { false } & 904487 \text { does not contain the digit } 2 \text { or } 6 \\\hline \text { containsBothDigits }(8,2,3) & \text { false } & 8 \text { does not contain the digit } 2 \text { or } 3\end{array}
Note: You may not use a String to solve this problem.


Definitions:

Units Sold

The total quantity of products or goods a company has sold during a particular period.

Adjusting Entries

Journal entries made before the preparation of financial statements to ensure that revenues and expenses are recognized in the period they occur.

Employee Discrimination Lawsuit

A legal claim brought by employees against an employer alleging unlawful discrimination in the workplace.

Product Liability Lawsuit

Legal action taken against a manufacturer or seller for producing or selling a defective product that causes injury or harm to the consumer.

Related Questions