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
The device whose operation closely matches the way the clamp-on ammeter works is
Ivanshal [37]

Answer:

The answer is

C. Split phase motor

Explanation:

Clamp meters rely on the principle of magnetic induction to make non contact AC current measurements. Electric current flowing through a wire produces a magnetic field.

Which is similar to basic mode of operation of electric motor and split phase motor is a type of electric motor.

What is a a clamp on meter?

Clamp meters are electrical testers which have wide jaws that are able to clamp around an electrical conductor. Originally designed as a single purpose tool for measuring AC current, clamp meters now include inputs for accepting test leads and other probes that support a wide range of electrical measurements, the jaws of a clamp meter permit work in tight spaces and permits current measurements on live conductors without circuit interruption.

6 0
3 years ago
Assume the following LTI system where the input signal is an impulse train (i.e.,x(t)=∑????(t−nT0)[infinity]n=−[infinity].a)Find
Igoryamba

Answer:

See explaination

Explanation:

The Fourier transform of y(t) = x(t - to) is Y(w) = e- jwto X(w) . Therefore the magnitude spectrum of y(t) is given by

|Y(w)| = |X(w)|

The phase spectrum of y(t) is given by

<Y(w) = -wto + <X(w)

please kindly see attachment for the step by step solution of the given problem.

4 0
3 years ago
Carnot heat engine A operates between 20ºC and 520ºC. Carnot heat engine B operates between 20ºC and 820ºC. Which Carnot heat en
nikklg [1K]

Answer:

engine B is more efficient.

Explanation:

We know that Carnot cycle is an ideal cycle for all working heat engine.In Carnot cycle there are four processes in which two are constant temperature processes and others two are isentropic process.

We also kn ow that the efficiency of Carnot cycle given as follows  

\eta =1-\dfrac{T_1}{T_2}

Here temperature should be in Kelvin.

For engine A

\eta =1-\dfrac{T_1}{T_2}

\eta =1-\dfrac{273+20}{520+273}

\eta =0.63

For engine B

\eta =1-\dfrac{T_1}{T_2}

\eta =1-\dfrac{273+20}{820+273}

\eta =0.73

So from above we can say that engine B is more efficient.

4 0
3 years ago
Explain why the following scenario fails to meet the definition of a project description.
s344n2d4d5 [400]

Answer:

The youth hockey training facility

Explanation:

7 0
3 years ago
A particular motor rotates at 3000 revolutions per minute. What is its speed in rad/sec, and how many seconds does it takes to m
Leno4ka [110]

Answer:

ω=314.15 rad/s.

0.02 s.

Explanation:

Given that

Motor speed ,N= 3000 revolutions per minute

N= 3000 RPM

The speed of the motor in rad/s given as

\omega=\dfrac{2\pi N}{60}\ rad/s

Now by putting the values in the above equation

\omega=\dfrac{2\pi \times 3000}{60}\ rad/s

ω=314.15 rad/s

Therefore the speed in rad/s will be 314.15 rad/s.

The speed in rev/sec given as

\omega=\dfrac{ 3000}{60}\ rad/s

ω= 50 rev/s

It take 1 sec to cover 50 revolutions

That is why to cover 1 revolution it take

\dfrac{1}{50}=0.02\ s

4 0
3 years ago
Other questions:
  • Pressurized steam at 450 K flows through a long, thin-walled pipe of 0.5-m diameter. The pipe is enclosed in a concrete casing t
    15·1 answer
  • A curve with 0.3 m constant radius contains a bead that is moving on it such that its rotational velocity is 3t2 sec-1. If the b
    12·1 answer
  • Write a method called compFloat5 which accepts as input two doubles as an argument (parameter). Write the appropriate code to te
    9·1 answer
  • In case of damaged prestressed concrete I girders which are used for restoring strength?
    9·1 answer
  • A wall in a house contains a single window. The window consists of a single pane of glass whose area is 0.15 m2 and whose thickn
    10·1 answer
  • Air at 20 C and 1 atm flows over a flat plate at 35 m/s. The plate is 75 cm long and is maintained at 60 с. Assuming unit depth
    8·1 answer
  • The Greek alphabet has 24 distinct lowercase letters. How many bits are needed to be able to encode any single lowercase Greek l
    9·1 answer
  • Which type of load generates a magnetic field?
    12·1 answer
  • Saferty precautions of drill press​
    8·2 answers
  • Which one of the following best defines hardness: (a) energy absorbed by a material when an object strikes its surface, (b) resi
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!