7. Complete the body y of digitAppears so it satisfies its contract. For full cr
ID: 3723853 • Letter: 7
Question
7. Complete the body y of digitAppears so it satisfies its contract. For full credit, you must use only kernel methods, recursion and one return statement For example, if n 1234, digitAppears(n, 4) returns true. Reports if digit appears in n when it is wnitten in ordinary decimal ensures digitappears- [if the digit digit appears in n) " notation. private static boolean digitAppears (NaturalNumber n, int digit)( 8 Complete the body of longest Text so it satisfies its contract. For full credit, you must use recursion and only one return statement Reports the text of the longest plain text node in the XMLTree t. eparam t @return the text of the longest plain text node in t the XMLTree * grequires [t has at least one plain text node] * gensures longest Text [the text of the longest plain text node in t] private static String longestText (xMLTree t) fExplanation / Answer
If you post more than 1 question, as per chegg guideines I have to solve only 1 question.
Ques 7.
private static boolean digitAppears(NaturalNumber n, int digit)
{
while( n > 0 )
{
// if the digit at ones place is same as digit
if( n % 10 == digit )
return true;
// remove the digit at ones place
n = n / 10;
}
return false;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.