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 =...

  • 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...

  • 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...

  • 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 = ""; }...

  • 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...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • I got stuck on these two steps, can someone help me ? ACCOUNTING CYCLE STEP 3:...

    I got stuck on these two steps, can someone help me ? ACCOUNTING CYCLE STEP 3: Post each trans me general ledger working papers provideo teach transaction in the general journal to the general ledger. Use s provided in your packet. Posting is the process of transferring general journal entry information to the seneral ledger. Fach number you post should be properly Cross-referenced Helpful Hints by: recording the general journal page number (ex. G1, G2, etc.) in the Posting Reference...

  • Please help me. package a1; public class Methods {    /*    * Instructions for students:...

    Please help me. package a1; public class Methods {    /*    * Instructions for students: Use the main method only to make calls to the    * other methods and to print some testing results. The correct operation of    * your methods should not depend in any way on the code in main.    *    * Do not do any printing within the method bodies, except the main method.    *    * Leave your testing code...

  • Problem Statement: A company intends to offer various versions of roulette game and it wants you...

    Problem Statement: A company intends to offer various versions of roulette game and it wants you to develop a customized object-oriented software solution. This company plans to offer one version 100A now (similar to the simple version in project 2 so refer to it for basic requirements, but it allows multiple players and multiple games) and it is planning to add several more versions in the future. Each game has a minimum and maximum bet and it shall be able...

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