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
Can some one plz give me brainlys
Brums [2.3K]

Answer:

how do u do that?

Explanation:

confusion

7 0
2 years ago
Read 2 more answers
Consider a resistor made of pure silicon with a cross-sectional area pf 0.5 μm2, and a length of 50 μm. What is the resistance o
lukranit [14]

Answer: 24 pA

Explanation:

As pure silicon is a semiconductor, the resistivity value is strongly dependent of temperature, as the main responsible for conductivity, the number of charge carriers (both electrons and holes) does.

Based on these considerations, we found that at room temperature, pure silicon resistivity can be approximated as 2.1. 10⁵  Ω  cm.

The resistance R of a given resistor, is expressed by the following formula:

R = ρ L / A

Replacing by the values for resistivity, L and A, we have

R = 2.1. 10⁵ Ω  cm. (10⁴ μm/cm). 50 μm/ 0.5 μm2

R = 2.1. 10¹¹ Ω

Assuming that we can apply Ohm´s Law, the current that would pass through this resistor for an applied voltage of 5 V, is as follows:

I = V/R = 5 V / 2.1.10¹¹ Ω = 2.38. 10⁻¹¹ A= 24 pA

7 0
3 years ago
A lagoon is designed to accommodate an input flow of 0.10 m^3/s of nonconservative pollutant with concentration 30 mg/L and deca
dexar [7]

Answer:

Volume of the lagoon required for the decay process must be larger than 86580 m³ = 8.658 × 10⁷ L

Explanation:

The lagoon can be modelled as a Mixed flow reactor.

From the value of the decay constant (0.2/day), one can deduce that the decay reaction of the pollutant is a first order reaction.

The performance equation of a Mixed flow reactor is given from the material and component balance thus:

(V/F₀) = (C₀ - C)/((C₀)(-r)) (From the Chemical Reaction Engineering textbook, authored by Prof. Octave Levenspiel)

V = volume of the reactor (The lagoon) = ?

C₀ = Initial concentration of the reactant (the pollutant concentration) = 30 mg/L = 0.03 mg/m³

F₀ = Initial flow rate of reactant in mg/s = 0.10 m³/s × C₀ = 0.1 m³/s × 0.03 mg/m³ = 0.003 mg/s

C = concentration of reactant at any time; effluent concentration < 10mg/L, this means the maximum concentration of pollutant allowed in the effluent is 10 mg/L

For the sake of easy calculation, C = the maximum value = 10 mg/L = 0.01 mg/m³

(-r) = kC (Since we know this decay process is a first order reaction)

This makes the performance equation to be:

(kVC₀/F₀) = (C₀ - C)/C

V = F₀(C₀ - C)/(kC₀C)

k = 0.2/day = 0.2/(24 × 3600s) = 2.31 × 10⁻⁶/s

V = 0.003(0.03 - 0.01)/(2.31 × 10⁻⁶ × 0.03 × 0.01)

V = 86580 m³

Since this calculation is made for the maximum concentration of 10mg/L of pollutant in the effluent, the volume obtained is the minimum volume of reactor (lagoon) to ensure a maximum volume of 10 mg/L of pollutant is contained in the effluent.

The lower the concentration required for the pollutant in the effluent, the larger the volume of reactor (lagoon) required for this decay reaction. (Provided all the other parameters stay the same)

Hope this helps!

5 0
3 years ago
Eight energy corporations made plans to increase their combined spending on efficiency programs to $50 million per year for the
tangare [24]

Answer:

F=531831381

Explanation:

There are two  ways of doing this question:

1) By Formula

2) By Using  Compound interest Table

By Formula:

F=A*\frac{(1+i)^{n}-1}{i}

Where:

F is future value

A is annual amount per year

i is interest rate

n is number of years

F=50 million*\frac{(1+0.08)^{8}-1}{0.08}

F=531831381

By Using  Compound interest Table:

F=A(F/A,i,n)

From Table F/A at i=8% and n=8 is 10.6366

F=50000000*(10.6366)

F=531830000≅531831381

The difference in two answers is due to decimal points if you take value from table to greater decimal points you will get the exact answer as by using formula.

7 0
3 years ago
Consider a continuous-flow, indraft supersonic wind tunnel, which uses a vacuum pump to draw atmospheric air from outside of the
BigorU [14]
I believe it’s B but I’m not sure
3 0
3 years ago
Other questions:
  • A sheet of steel 4.4 mm thick has nitrogen atmospheres on both sides at 1200°C and is permitted to achieve a steady-state diffus
    10·1 answer
  • A 3.52 kg steel ball is tossed upward from a height of 6.93 meters above the floor with a vertical velocity of 2.99 m/s. What is
    14·1 answer
  • The combustion chamber has different shapes depending on the make and model of the engine. True or false
    8·1 answer
  • Pehdhdjdjdodnjdndjdjdjfjdk
    11·2 answers
  • In a surface grinding operation, the wheel diameter = 8.0 in, wheel width = 1.0 in, wheel speed = 6000 ft/min, work speed = 40 f
    9·1 answer
  • An ideal vapor-compression refrigeration cycle using refrigerant-134a as the working fluid is used to cool a brine solution to −
    12·1 answer
  • How does the Ivanpah Solar Plant make electricity?
    12·1 answer
  • Planetary gears require the armature to be offset via a gear housing that holds the starter drive.
    12·2 answers
  • Kyla has obtained a bachelor’s degree in electronics engineering. In her search for a job, she comes across an advertisement tha
    11·1 answer
  • determine the position d of the 6- kn load so that the average normal stress in each rod is the same.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!