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
What are the important factors needed to be considered while selecting a brake or clutch?
AysviL [449]

Answer:

The correct answer is: the following factors are needed to properly consider while selecting a brake or clutch:

-Engagement

-Friction

-Electromagnetic

-Mechanical

-Actuation

-Electric

-Fluid power

-Self-actuation

-Key concepts

-Application notes

-Selection criteria

Explanation:

Clutches and brakes are important devices in many rotating drive systems, it is very important to guarantee the security and the proper function of them accomplishing a high quality parameters in those factors.

4 0
3 years ago
What are the inputs and outputs of a sailboat?
bearhunter [10]

Answer:

  • sailing ships were the primary means of maritime trade and transportation; exploration across the seas and oceans was reliant on sail for anything other than the shortest distances. Naval power in this period used sail to varying degrees depending on the current technology, culminating in the gun-armed sailing warships of the Age of Sail.
7 0
2 years ago
Do the coil resistances have any effect on the plots?
PolarNik [594]
Because of the skin depth effect, the current at high frequency tends to flow at very low depth from radius. Then at high frequency the effective cross section of the wire is narrower than at DC.

Fro example skin depth at 100 kHz is 0.206 mm (0.008”), a wire more thicker than AWG26 could be a waste of copper, better use a bunch of thin wire (Litz wire) to rise the Q factor.
8 0
3 years ago
YO CUTIE! HELP MEEEEEE! Hazardous waste is a category that includes all of the following EXCEPT
madam [21]

your answer should be <u>B. Soluble</u>

3 0
3 years ago
Read 2 more answers
Water flows at low speed through a circular tube with inside diameter of 2 in. A smoothly contoured body of 1.5 in. diameter is
Art [367]

Answer:

Pressure = 11.38 psi

Force = 13.981 Ibf

Explanation:

Step by step solution is in the attached document.

5 0
3 years ago
Other questions:
  • Describe three advantages and three disadvantages of JIT?
    12·1 answer
  • Air enters the compressor of an ideal cold air-standard Brayton cycle at 100 kPa, 300 K, with a mass flow rate of 6 kg/s. The co
    11·1 answer
  • What are the causes of electric shock​
    13·1 answer
  • The sports car has a weight of 4900 lblb and center of gravity at GG. If it starts from rest it causes the rear wheels to slip a
    13·1 answer
  • What additional information would make the following problem statement stronger? Select all that apply.
    8·1 answer
  • Which state did NOT have people that got sick from the
    10·1 answer
  • A school is playing $0.XY per kWh for electric power. To reduce its power bill, the school installs a wind turbine with a rated
    6·1 answer
  • A step-up transformer has 20 primary turns and 400 secondary turns. If the primary current is 30 A, what is the secondary curren
    15·1 answer
  • Does anyone know how to fix this? It's a chromebook and project where I have to try to fix it​
    9·1 answer
  • Use the map to answer the question.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!