1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alukav5142 [94]
3 years ago
12

Let’s define a new language called dog-ish. A word is in the lan- guage dog-ish if the word contains the letters ’d’, ’o’, ’g’ a

re in the word in order. For example, "dpoags" would be in dog-ish because dpoags. Other words like "dog", "doooooog", "pdpopgp", and "qwqwedqweqweoqweqw- gasd" would be in dog-ish. "cat", "apple", "do", "g", would not be in dog-ish.
(a) (20 points) Define the method inDogish recursively such that it re- turns true if the word is in dog-ish and false if it is not. I left a dogishHelper method, which I guarantee you will need to recursively solve dogish. An iterative solution will receive no points.

(b) (20 points) Define the method inXish that does the same logic of dog- ish but for some word X. The method returns true if the word contains all the letters in the word X. The solution must be recursive. An iterative solution will receive no points.

class Main {public static void main(String[] args) {/* leave this main method blank but feel free to uncomment below linesto test your code */// System.out.println(dogish("aplderogad"));// System.out.println(dogishGeneralized("aplderogad", "dog"));} // returns true if the word is in dog-ish// returns false if word is not in dog-ishpublic static boolean inDogish(String word){return false;} // necessary to implement inDogish recursivelypublic static boolean dogishHelper(String word, char letter) {return false;} // a generalized version of the inDogish methodpublic static boolean inXish(String word, String x){return false;}}

Engineering
1 answer:
attashe74 [19]3 years ago
5 0

Answer and Explanation:

// code

class Main {

   public static void main(String[] args) {

       /*

        *

        *

        * your code

        *

        */

       System.out.println(inDogish("aplderogad"));

       System.out.println(inXish("aplderogad", "dog"));

   }

   // returns true if the word is in dog-ish

   // returns false if word is not in dog-ish

   public static boolean inDogish(String word) {

       // first find d

       if (dogishHelper(word, 'd')) {

           // first find string after d

           String temp = word.substring(word.indexOf("d"));

           // find o

           if (dogishHelper(temp, 'o')) {

               // find string after o

               temp = temp.substring(temp.indexOf("o"));

               // find g

               if (dogishHelper(temp, 'g'))

                   return true;

           }

The output is attached below

       }

       return false;

   }

   // necessary to implement inDogish recursively

   public static boolean dogishHelper(String word, char letter) {

       // end of string

       if (word.length() == 0)

           return false;

       // letter found

       if (word.charAt(0) == letter)

           return true;

       // search in next index

       return dogishHelper(word.substring(1), letter);

   }

   // a generalized version of the inDogish method

   public static boolean inXish(String word, String x) {

       if (x.length() == 0)

           return true;

       if (word.length() == 0)

           return false;

       if (word.charAt(0) == x.charAt(0))

           return inXish(word.substring(1), x.substring(1));

       return inXish(word.substring(1), x.substring(0));

   }

}

PS E:\fixer> java Main true true ne on

PS E:\fixer> java Main true true ne on

You might be interested in
Gtjffs
grandymaker [24]

the required documents is 3000

4 0
2 years ago
The basic barometer can be used to measure the height of a building. If the barometric readings at the top and the bottom of a b
Levart [38]

Answer:

230.51 m

Explanation:

Pb = 695 mmHg

Pt = 675 mmHg

Pb - Pt = 20 mmHg

Calculate dP:

dP = p * g * H = (13600)*(9.81)*(20/1000) = 2668.320 Pa

Calculate Height of building as dP is same for any medium of liquid

dP = p*g*H = 2668.320

H = 2668.32 / (1.18 * 9.81) = 230.51 m

8 0
3 years ago
The Torricelli's theorem states that the (velocity—pressure-density) of liquid flowing out of an orifice is proportional to the
Sergeeva-Olga [200]

Answer:

The correct answer is 'velocity'of liquid flowing out of an orifice is proportional to the square root of the 'height'  of liquid above the center of the orifice.

Explanation:

Torricelli's theorem states that

v_{exit}=\sqrt{2gh}

where

v_{exit} is the velocity with which the fluid leaves orifice

h is the head under which the flow occurs.

Thus we can compare the given options to arrive at the correct answer

Velocity is proportional to square root of head under which the flow occurs.

4 0
3 years ago
State the four advantages of levers
dezoksy [38]

Answer:

Here are 2 sense i cant find 4

Explanation:

Levers are used to multiply force, In other words, using a lever gives you greater force or power than the effort you put in.

In a lever, if the distance from the effort to the fulcrum is longer than the distance from the load to the fulcrum, this gives a greater mechanical advantage.

3 0
2 years ago
Write an ALP to separate odd and even numbers from an array of N numbers; arrange odd
Marta_Voda [28]

Below is the program to separate odd and even numbers                                  

<u>Explanation</u>:

<u>L1:</u>

         mov ah,00

         mov al,[BX]

         mov dl,al

         div dh

         cmp ah,00

         je EVEN1

         mov [DI],dl

         add OddAdd,dl

         INC DI

         INC BX

         Loop L1

         jmp CAL

    <u>EVEN1:</u>

         mov [SI],dl

         add Even Add,dl

         INC SI

         INC BX

         Loop L1

    <u>CAL:   </u>  

         mov ax,0000

         mov bx,0000

         mov al,OddAdd

         mov bl,EvenAdd

         MOV  ax,4C00h

         int 21h

end

The above program separates odd and even numbers from the array using 8086 microprocessor. It has odd numbers in 2000h and even numbers in 3000h.

6 0
3 years ago
Other questions:
  • A device is needed to accelerate a 3000 lb vehicle into a barrier with constant velocity to test its 5 mph bumpers. The vehicle
    12·2 answers
  • For the SR-latch below high levels of Set and Reset result in Q= 1 and 0, respectively. The next state is unknown when both inpu
    12·1 answer
  • A steel bar is 150 mm square and has a hot-rolled finish. It will be used in a fully reversed bending application. Sut for the s
    7·1 answer
  • A civil engineer is asked to design a curved section of roadway that meets the following conditions: With ice on the road, when
    13·1 answer
  • A piston-cylinder assembly has initially a volume of 0.3 m3 of air at 25 °C. Mass of the air is 1 kg. Weights are put on the pis
    15·1 answer
  • In using the drag coefficient care needs to be taken to use the correct area when determining the drag force. What is a typical
    7·1 answer
  • It is the tool used to measure the amount of electric current​
    6·2 answers
  • How many astronauts work<br> in the International Space Station
    7·1 answer
  • Please what is dif<br>ference between building technology and building engineering.​
    14·2 answers
  • Is A fine by the EPA may be imposed on the employer or
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!