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]
2 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]2 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
At an axial load of 22 kN, a 15-mm-thick × 40-mm-wide polyimide polymer bar elongates 4.1 mm while the bar width contracts 0.15
Alenkasestr [34]

Answer:

The Poisson's Ratio of the bar is 0.247

Explanation:

The Poisson's ratio is got by using the formula

Lateral strain / longitudinal strain

Lateral strain = elongation / original width (since we are given the change in width as a result of compession)

Lateral strain = 0.15mm / 40 mm =0.00375

Please note that strain is a dimensionless quantity, hence it has no unit.

The Longitudinal strain is the ratio of the elongation to the original length in the longitudinal direction.

Longitudinal strain = 4.1 mm / 270 mm = 0.015185

Hence, the Poisson's ratio of the bar is 0.00375/0.015185 = 0.247

The Poisson's Ratio of the bar is 0.247

Please note also that this quantity also does not have a dimension

3 0
3 years ago
What did the Spanish have that the Aztecs didn’t
notsponge [240]

Answer:

The Spanish brought chickenpox, smallpox, measles, mumps, and rubella to the new world. These diseases killed 75% of the Native Americans. ... The advantages that the Spanish had over the Aztecs were 16 horses, guns, armor, formed alliances, and diseases, steel.

Explanation:

I hope this helped!

6 0
3 years ago
(1.24) Consumer Reports is doing an article comparing refrigerators in their next issue. Some of the characteristics to be inclu
kondaur [170]

Answer:

“height is a quantitative variable ”

Explanation:

According to the question asked, answer is “height is a quantitative variable ”

Height is a quantitative variable because it is related to the measurement and in measurement, when we measure something we deal with number (numerical data)

Numerical data is a type of quantitative data that is why we say “height is a quantitative variable”  

There are some other possible questions in the given paragraph which I would like to mention here,  are as following:

Which are the categorical variables in the given report?

<u>Answer: </u>Energy star complaints

Top, Bottom or side-by-side freezer

Which are the quantitative variables in the given report?

<u>Answer:</u> Estimated Energy Consumption in kilowatts

Width, depth, and height in inches

Capacity in Cubic Feet  

What are the individuals in the report?

<u>Answer: </u>The brand name and model  

8 0
2 years ago
What is chemical engineering​
viktelen [127]

Answer:

Chemical engineering is the branch of engineering that deals with chemical production and the manufacture of products through chemical processes

Explanation:

8 0
3 years ago
calculate how much black eyes seeds are necessary to plant a 6- hectare( 14.425 acres) field. given that the weight of 1000 blac
11111nata11111 [884]

Answer: 1.38g

Explanation:

Width of planting area = 100m

Field size = 6-hectares(14.425 acres)

Weight of 1000 black eye seed = 230g

1 lb = 453.4g

1 black eye seed = 230g/1000 = 0.23g = 0.00023kg

1 hectare = 10,000sq metre

6 hectare = 60,000sq metre

(Weight/Area) kg/m2

0.00023kg / 10,000 = 2.3×10^-8kg/m^2

And field size = 6hectares = 60,000m^2

(2.3×10^-8) × 60,000 = 0.00138kg of black eye seed

0.00138kg × 1000 = 1.38g

6 0
3 years ago
Other questions:
  • In highways the far left lane is usually the _____
    11·2 answers
  • An AC generator supplies an rms voltage of 120 V at 50.0 Hz. It is connected in series with a 0.650 H inductor, a 4.80 μF capaci
    6·1 answer
  • 3. (20 points) Suppose we wish to search a linked list of length n, where each element contains a key k along with a hash value
    7·1 answer
  • What are practical considerations you might encounter when you increase the moment of inertia (I) while keeping the cross-sectio
    13·1 answer
  • DE QUE MANERA LA ALEGRIA NOS AYUDA A CONSEGIR AMIGOS <br> ≤→ω←≥
    10·1 answer
  • What Are 2 Properties electromagnets have that permanent magnets do not?
    8·2 answers
  • WHICH TASK BEST FITS THE ROLE OF A DESIGN ENGINEER ?
    7·1 answer
  • What is digital communication?​
    6·1 answer
  • How to engineering equation solving
    12·1 answer
  • How much does it cost to replace a roof on a 2,200 square foot house.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!