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
A motor is mounted on a platform that is observed to vibrate excessively at an operating speed of 6000 rpm producing a 250-N for
vichka [17]

Answer:

The amplitude of the absorbed mass can be found

for ka:

X_{a} =0.002m=\frac{F_{0} }{K_{a} } =\frac{250}{K_{a} } =125000N/m

now

w^2=\frac{K_{a} }{m_{a} } \\m_{a} =\frac{K_{a} }{w^2} =\frac{125000}{[6000*2\pi /60]^2} =0.317kg

4 0
3 years ago
Compressed Air In a piston-cylinder device, 10 gr of air is compressed isentropically. The air is initially at 27 °C and 110 kPa
Helen [10]

Answer:

(a) 2.39 MPa (b) 3.03 kJ (c) 3.035 kJ

Explanation:

Solution

Recall that:

A 10 gr of air is compressed isentropically

The initial air is at = 27 °C, 110 kPa

After compression air is at = a450 °C

For air,  R=287 J/kg.K

cv = 716.5 J/kg.K

y = 1.4

Now,

(a) W efind the pressure on [MPa]

Thus,

T₂/T₁ = (p₂/p₁)^r-1/r

=(450 + 273)/27 + 273) =

=(p₂/110) ^0.4/1.4

p₂ becomes  2390.3 kPa

So, p₂ = 2.39 MPa

(b) For the increase in total internal energy, is given below:

ΔU = mCv (T₂ - T₁)

=(10/100) (716.5) (450 -27)

ΔU =3030 J

ΔU =3.03 kJ

(c) The next step is to find the total work needed in kJ

ΔW = mR ( (T₂ - T₁) / k- 1

(10/100) (287) (450 -27)/1.4 -1

ΔW = 3035 J

Hence, the total work required is = 3.035 kJ

4 0
3 years ago
Fluid power is a. The technology that deals with the generation, control, and transmission of power-using pressurized fluids b.
snow_tiger [21]

Answer:  a) The technology that deals with the generation, control and transmission of power using pressurized fluids

Explanation: Fluid power is defined as the fluids which are under pressure and then are used for generation,control and transmit the power. Fluid power systems produces high forces as well as power in small amount . These systems usually tend to have better life if maintained properly. The force that are applied on this system can be monitored by gauges as well as meter.

8 0
3 years ago
An automated transfer line is to be designed. Based on previous experience, the average downtime per occurrence = 5.0 min, and t
IRINA_888 [86]

Answer:

a) 28 stations

b) Rp = 21.43

E = 0.5

Explanation:

Given:

Average downtime per occurrence = 5.0 min

Probability that leads to downtime, d= 0.01

Total work time, Tc = 39.2 min

a) For the optimum number of stations on the line that will maximize production rate.

Maximizing Rp =minimizing Tp

Tp = Tc + Ftd

=  \frac{39.2}{n} + (n * 0.01 * 5.0)

= \frac{39.2}{n} + (n * 0.05)

At minimum pt. = 0, we have:

dTp/dn = 0

= \frac{-39.2}{n^2} + 0.05 = 0

Solving for n²:

n^2 = \frac{39.2}{0.05} = 784

n = \sqrt{784} = 28

The optimum number of stations on the line that will maximize production rate is 28 stations.

b) Tp = \frac{39.2}{28} + (28 * 0.01 * 5)

Tp = 1.4 +1.4 = 2.8

The production rate, Rp =

\frac{60min}{2.8} = 21.43

The proportion uptime,

E = \frac{1.4}{2.8} = 0.5

3 0
3 years ago
The cantilevered W530 x 150 beam shown is subjected to a 9.8-kN force F applied by means of a welded plate at A. Determine the e
snow_lady [41]

The <em>equivalent force-couple system</em> at O is the force and couple experienced when at point O due to the applied force at point A

The <em>equivalent force couple</em> system at O due to force <em>F</em> are;

Force, F =  (<u>8.65·i - 4.6·j</u>) KN

Couple, M₀ ≈ <u>40.9 </u>k kN·m

The reason the above values are correct is as follows:

The known values for the <em>cantilever</em> are;

The <em>height </em>of the beam = 0.65 m

The <em>magnitude of </em>the applied <em>force</em>, F = 9.8 kN

The <em>length </em>of the beam = 4.9 m

The <em>angle </em>away from the vertical the force is applied = 26°

The required parameter:

The <em>equivalent force-couple system</em> at the centroid of the beam cross-section of the cantilever

Solution:

The <em>equivalent force-couple system</em> is the force-couple system that can replace the given force at centroid of the beam cross-section at the cantilever O ;

The <em>equivalent force</em> \overset \longrightarrow F = 9.8 kN × cos(28°)·i - 9.8 kN × sin(28°)·j

Which gives;

The <em>equivalent force</em> \overset \longrightarrow F ≈ (<u>8.65·i - 4.6·j</u>) KN

The <em>couple </em><em>acting </em>at point O due to the force <em>F</em> is given as follows;

The <em>clockwise moment</em> = <em>9.8 kN × cos(28°) × 4.9</em>

The <em>anticlockwise moment</em> = <em>9.8 kN × sin(28°) 0.65/2 </em>

The sum of the moments = Anticlockwise moment - Clockwise moments

∴ The <em>sum </em>of the moments, ∑M, gives the moment acting at point O as follows;

M₀ = <em>9.8 kN × sin(28°) 0.65/2 - 9.8 kN × cos(28°) × 4.9</em>  ≈ 40.9 kN·m

The couple acting at O, due to F,  M₀ ≈ <u>40.9 kN·m</u>

The equivalent force couple system acting at point O due the force, F, is as follows

F =  (8.65·i - 4.6·j) KN

M₀ ≈ <u>40.9 </u>k kN·m

Learn more about equivalent force systems here:

brainly.com/question/12209585

4 0
3 years ago
Other questions:
  • To cool a summer home without using a vapor compression refrigeration cycle, air is routed through a plastic pipe (k=0.15 W/m*K,
    15·1 answer
  • In electric heaters, electrical energy is converted to potential energy. a)-True b)-false?
    11·1 answer
  • NO reacts with Br2 in the gas phase according to the following chemical equation: 2NO(g) +Br2(g)2NOBr(g) It is observed that, wh
    6·1 answer
  • In very early human history, complex sanitation systems were not needed because settlements were usually very small, like the vi
    10·2 answers
  • A 2.2-kg model rocket is launched vertically and reaches an altitude of 70 m with a speed of 30 m/s at the end of powered flight
    5·1 answer
  • Lockheed Martin Skunk Works designs and produces aircraft for defense using rapid prototyping tools
    11·1 answer
  • A single phase molor is located
    14·1 answer
  • Select the correct answer. Ruby wants to create a cube puzzle game. For that she has to create a cube. Which drafting tool do yo
    7·1 answer
  • 9
    15·1 answer
  • Subject : SCIENCE
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!