Question
Can someone help me with these two 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) f
0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you post more than 1 question, as HOMEWORKLIB RULES 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;

}

Add a comment
Know the answer?
Add Answer to:
Can someone help me with these two question? 7. Complete the body y of digitAppears so...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • CAN SOMEONE PLEASE SOLVE THIS? THANK YOU. FINALTREE.JAVA: import java.util.LinkedList; public class FinalTree<E extends Comparable<? super...

    CAN SOMEONE PLEASE SOLVE THIS? THANK YOU. FINALTREE.JAVA: import java.util.LinkedList; public class FinalTree<E extends Comparable<? super E>> { private Node<E> root; private int size; public FinalTree() { root = null; size = 0; } public boolean isEmpty() { return size == 0; } public void add(E newItem) { if (isEmpty()) { root = new Node<E>(newItem); } else { Node<E> parent = null; Node<E> temp = root; int result = 0; while (temp != null) { parent = temp; result =...

  • Code in C++. Can someone make it so that the code below can be compiled? ▪...

    Code in C++. Can someone make it so that the code below can be compiled? ▪ Creating an empty queue ▪ Inserting a value ▪ Removing a value ▪ Finding the size of the queue ▪ Printing the contents of the queue ▪ Adding the contents of one queue to the end of another ▪ Merging the contents of two queues into a third, new, queue Class Attributes Your class should be implemented using a linked list and should have...

  • i need help to edit the two methods below so that i can have them work...

    i need help to edit the two methods below so that i can have them work in the class provided after the two methods. Insert and Select methods below public void insert(String pCode, String pName,String pDesc, double c){ setProcCode(pCode); setProcName(pName); setProcDesc(pDesc); setCost(c); try { FileWriter ff=new FileWriter("Procedures.txt",true); BufferedWriter b=new BufferedWriter(ff); PrintWriter pp=new PrintWriter(b); pp.println(pCode+":"+pName+":"+pDesc+":"+c); pp.close(); } catch(Exception ep){ ep.printStackTrace(); } } public void select(String pCode){ try{ FileReader ff=new FileReader("Procedures.txt"); BufferedReader b=new BufferedReader(ff); String ll; StringTokenizer tt; while((ll=b.readLine())!=null){ tt=new StringTokenizer(ll,":"); String...

  • Hello can someone help me in my code I left it as comment  task #0, task#1, task#2a...

    Hello can someone help me in my code I left it as comment  task #0, task#1, task#2a and task#2b the things that I am missing I'm using java domain class public class Pizza { private String pizzaCustomerName; private int pizzaSize; // 10, 12, 14, or 16 inches in diameter private char handThinDeep; // 'H' or 'T' or 'D' for hand tossed, thin crust, or deep dish, respecitively private boolean cheeseTopping; private boolean pepperoniTopping; private boolean sausageTopping; private boolean onionTopping; private boolean...

  • Here is what I got so far also can anyone help me align the output #include...

    Here is what I got so far also can anyone help me align the output #include <iostream> #include <iomanip> using namespace std; class Person { private: string name;    public: Person() { name = ""; } Person(string name) { this->name = name; } string getName() { return name; } void setName(string name) { this-> name = name; } }; class Publication { private: int pubNumber; string title; Person borrower;    public: static int count; Publication() { title = ""; }...

  • Programming Assignment #7 (Recursion) This assignment is to write some methods that perform simple array operations...

    Programming Assignment #7 (Recursion) This assignment is to write some methods that perform simple array operations recursively. Specifically, you will write the bodies for the recursive methods of the ArrayRecursion class, available on the class web page. No credit will be given if any changes are made to ArrayRecursion.java, other than completing the method bodies Note that the public methods of ArrayRecursion – contains(), getIndexOfSmallest(), and sort() – cannot be recursive because they have no parameters. Each of these methods...

  • can someone please double check my code here are the requirements please help me fulfill the...

    can someone please double check my code here are the requirements please help me fulfill the requirements Using the material in the textbook (NumberList) as a sample, design your own dynamic linked list class (using pointers) to hold a series of capital letters. The class should have the following member functions: append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges...

  • Java programming help My program wont run. could someone tell me why. everything seems correct to...

    Java programming help My program wont run. could someone tell me why. everything seems correct to me... giving me the error: Exception in thread "main" java.lang.NumberFormatException: For input string: "Stud" at java.base/java.lang.NumberFormatException.forInputString(Unknown Source) at java.base/java.lang.Integer.parseInt(Unknown Source) at java.base/java.lang.Integer.parseInt(Unknown Source) at Util.readFile(Util.java:35) at Driver.main(Driver.java:8) _________________________________________________________________________________________________________________________ Program Prompt: Write a program to perform statistical analysis of scores for a class of students.The class may have up to 40 students.There are five quizzes during the term. Each student is identified by a four-digit...

  • Can you help me with the last part of the question? Problem 16-01 The stockholders' equity...

    Can you help me with the last part of the question? Problem 16-01 The stockholders' equity section of Flounder Inc. at the beginning of the current year appears below. Common stock, $10 par value, authorized 995,000 shares, 309,000 shares issued and outstanding Paid-in capital in excess of par-common stock Retained earnings $3,090,000 623,000 539,000 During the current year, the following transactions occurred. 1. The company issued to the stockholders 102,000 rights. Ten rights are needed to buy one share of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT