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
Explain three (3) modes of heat transfer in air conditioning system.
LenKa [72]

Answer:

1. Conduction

2. Convection

3. Radiation

Explanation:

The 3 modes of heat transfer i an air conditioning system:

1. Conduction:

The transfer of heat by conduction  takes place in solid and is when the conduction takes place as a result of direct contact in between the interacting material which transfer the heat energy from particle to particle thus conducting the heat through out the system.

2. Convection:

The other mode for the transfer of heat which takes place especially in fluids - gases and liquids is through the technique of convection in which the transfer of heat takes place by the circular motion of the atoms and molecules of the fluid which carries the heat energy and results in the distribution of the heated fluid in the entire system thus transferring all the heat energy in the entire system.

3. Radiation:

The third mode of heat transfer in the air conditioning system is through radiation. This method transfers the heat by making use of the electro-magnetic radiation in the infra red spectrum where the waves of the spectrum transfers the heat energy with the help of a medium or without any medium at all.

Thus making the radiation method of heat transfer as the only method out of the three methods which does not require the material medium for the transfer of heat energy.

4 0
3 years ago
A 12-ft high retaining wall has backfill of granular soil with an internal angle of friction of 30 and unit weight of 125 pef. W
irakobra [83]

Answer:

P_p = 27000 psf

Explanation:

given,

height of the retaining wall = h = 12 ft

internal angle of friction (∅)= 30°

unit weight = 125 pcf

Rankine passive earth pressure = ?

k_p is the coefficient of passive earth pressure

k_p = \dfrac{1 + sin\phi}{1 - sin\phi}

k_p = \dfrac{1 + sin30^0}{1 - sin30^0}

k_p = 3

Passive earth pressure

P_p = \dfrac{1}{2}k_p \gamma H^2

P_p = \dfrac{1}{2}\times 3\times 125 \times 12^2

      P_p = 27000 psf

Rankine passive earth pressure on the wall is equal to P_p = 27000 psf

7 0
3 years ago
A solid shaft and a hollow shaft of the same material have same length and outer radius R. The inner radius of the hollow shaft
alexandr402 [8]

Answer with Explanation:

By the equation or Torque we have

\frac{T}{I_{p}}=\frac{\tau }{r}=\frac{G\theta }{L}

where

T is the torque applied on the shaft

I_{p} is the polar moment of inertia of the shaft

\tau is the shear stress developed at a distance 'r' from the center of the shaft

\theta is the angle of twist of the shaft

'G' is the modulus of rigidity of the shaft

We know that for solid shaft I_{p}=\frac{\pi R^4}{2}

For a hollow shaft I_{p}=\frac{\pi (R_o^4-R_i^4)}{2}

Since the two shafts are subjected to same torque from the relation of Torque we have

1) For solid shaft

\frac{2T}{\pi R^4}\times r=\tau _{solid}

2) For hollow shaft we have

\tau _{hollow}=\frac{2T}{\pi (R^4-0.7R^4)}\times r=\frac{2T}{\pi 0.76R^4}

Comparing the above 2 relations we see

\frac{\tau _{solid}}{\tau _{hollow}}=0.76

Similarly for angle of twist we can see

\frac{\theta _{solid}}{\theta _{hollow}}=\frac{\frac{LT}{I_{solid}}}{\frac{LT}{I_{hollow}}}=\frac{I_{hollow}}{I_{solid}}=1.316

Part b)

Strength of solid shaft = \tau _{max}=\frac{T\times R}{I_{solid}}

Weight of solid shaft =\rho \times \pi R^2\times L

Strength per unit weight of solid shaft = \frac{\tau _{max}}{W}=\frac{T\times R}{I_{solid}}\times \frac{1}{\rho \times \pi R^2\times L}=\frac{2T}{\rho \pi ^2R^5L}

Strength of hollow shaft = \tau '_{max}=\frac{T\times R}{I_{hollow}}

Weight of hollow shaft =\rho \times \pi (R^2-0.7R^2)\times L

Strength per unit weight of hollow shaft = \frac{\tau _{max}}{W}=\frac{T\times R}{I_{hollow}}\times \frac{1}{\rho \times \pi (R^2-0.7^2)\times L}=\frac{5.16T}{\rho \pi ^2R^5L}

Thus \frac{Strength/Weight _{hollow}}{Strength/Weight _{Solid}}=5.16

3 0
4 years ago
A 1m3 tank containing air at 25℃ and 500kPa is connected through a valve to
Aliun [14]

Answer:

The right answer is "2.2099 m³".

Explanation:

Given:

Mass,

m = 5 kg

Temperature,

T = 35℃

or,

  = 35 + 273

Pressure,

P = 200 kPa

Gas constant,

R = 0.2870 kj/kgK

By using the ideal gas equation,

The volume will be:

⇒ PV=mRT

or,

⇒    V=\frac{mRT}{P}

By substituting the values, we get

          =\frac{5(0.2870)(35+273)}{200}

          =\frac{441.98}{200}

          =2.2099 \ m^3

8 0
3 years ago
Determine the location of the maximum bending moment. In the formula, w is the rate of load increase in lb ft and l is the lengt
Debora [2.8K]

https://vm.tiktok.com/ZSeMW4ttQ/ https://vm.tiktok.com/ZSeMW4ttQ/ https://vm.tiktok.com/ZSeMW4ttQ/ https://vm.tiktok.com/ZSeMW4ttQ/

4 0
3 years ago
Other questions:
  • If the contact surface between the 20-kg block and the ground is smooth, determine the power of force F when t = 4 s. Initially,
    14·1 answer
  • A circuit has a 24 volt battery and a resistor that is 8 ohms. How many amps are running through the circuit?
    6·1 answer
  • A battery rated at 7.2 V and 10000 J is connected across a light bulb. Assume that the internal resistance of the battery is neg
    14·1 answer
  • Steam enters a turbine operating at steady state with a mass flow of 10 kg/s, a specific enthalpy of 3100 kJ/kg, and a velocity
    6·1 answer
  • Consider two water tanks filled with water. The first tank is 8 m high and is stationary, while the second tank is 2 m high and
    12·2 answers
  • Design a digital integrator using the impulse invariance method. Find and give a rough sketch of the amplitude response, and com
    15·1 answer
  • While discussing armature testing: Technician A says to test for shorts, place the ohmmeter leads on a commutator segment and ar
    6·1 answer
  • Which of the following demonstrates a typical project benchmark progression?
    9·2 answers
  • Draw a sinusoidal signal and illustrate how quantization and sampling is handled by
    8·1 answer
  • In the last 5 meters of braking, you lose ___ of your speed.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!