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 two types of outlets that are found in an electrical system are:______
Dmitry [639]

Answer:

a. lighting and receptacle outlets

Explanation:

The two types of outlets that are found in an electrical system are

a. lighting and receptacle outlets

Outlets allow electrical equipment to connect to the electrical grid. The electrical grid provides alternating current to the outlet.

3 0
3 years ago
Which word from the passage best explains what the web in the passage symbolizes
frez [133]

Answer:

I cant see the passage

Explanation:

I cant see the passage

6 0
3 years ago
Concrete ___ support and anchor the bottom of steel columns and wood post, which support beams that are pare of framing system o
dolphi86 [110]
I wanna say it’s D post support
3 0
3 years ago
Pipe (2) is supported by a pin at bracket C and by tie rod (1). The structure supports a load P at pin B. Tie rod (1) has a diam
Galina-37 [17]

Answer:

P_max = 25204 N

Explanation:

Given:

- Rod 1 : Diameter D = 12 mm , stress_1 = 110 MPa

- Rod 2: OD = 48 mm , thickness t = 5 mm , stress_2 = 65 MPa

- x_1 = 3.5 mm ; x_2 = 2.1 m ; y_1 = 3.7 m

Find:

- Maximum Force P_max that this structure can support.

Solution:

- We will investigate the maximum load that each Rod can bear by computing the normal stress due to applied force and the geometry of the structure.

- The two components of force P normal to rods are:

               Rod 1 : P*cos(Q)  

               Rod 2: - P*sin(Q)

where Q: angle subtended between x_1 and Rod 1 @ A. Hence,

               Q = arctan ( y_1 / x_1)

               Q = arctan (3.7 / 2.1 ) = 60.422 degrees.

- The normal stress in each Rod due to normal force P are:

               Rod 1 : stress_1 = P*cos(Q)  / A_1

               Rod 2: stress_2 = - P*sin(Q)  / A_2

- The cross sectional Area of both rods are A_1 and A_2:

               A_1 = pi*D^2 / 4

               A_2 = pi*(OD^2 - ID^2) / 4

- The maximum force for the given allowable stresses are:

               Rod 1: P_max =  stress_1 * A_1 / cos(Q)

                          P_max = (110*10^6)*pi*0.012^2 / 4*cos(60.422)

                          P_max = 25203.61848 N

               Rod 2: P_max =  stress_2 * A_2 / sin(Q)

                          P_max = (65*10^6)*pi*(0.048^2 - 0.038^2) / 4*sin(60.422)

                          P_max = 50483.4 N

- The maximum force that the structure can with-stand is governed by the member of the structure that fails first. In our case Rod 1 with P_max = 25204 N.

             

8 0
3 years ago
In what type of automobile is a transaxle most commonly found?
user100 [1]

Answer: vehicles with a front engine and FWD or a rear engine and RWD.

Explanation But the transaxle can also be integrated into the rear axle on cars with a front engine and rear-wheel drive. The transaxle is in the rear where the differential would be rather than beside the engine.

7 0
3 years ago
Other questions:
  • In a particular application involving airflow over a heated surface, the boundary layer temperature distribution may be approxim
    6·1 answer
  • A triangular roadside channel is poorly lined with riprap. The channel has side slopes of 2:1 (H:V) and longitudinal slope of 2.
    9·1 answer
  • Find the volume of the rectangular prism<br> 9 cm<br> 10 cm
    8·1 answer
  • E xercise 17.1.2: For each of the transactions of Exercise 17.1.1, add the read- and write-actions to the computation and show t
    12·1 answer
  • Which source would be the best to base a hypothesis upon
    9·1 answer
  • A low-resistance path in a circuit, commonly called a _____ can cause a circuit breaker to trip
    7·1 answer
  • TP-6 What should you do when fueling an outboard boat with a portable tank?
    12·1 answer
  • Are there any companies that you can get a job at as an air craft engeer after university​
    14·1 answer
  • A. How is a decision matrix useful during the
    13·1 answer
  • How to engineering equation solving
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!