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
Derive the probability that a receptor is occupied by a ligand using a model that treats the L ligands in solution as distinguis
love history [14]

that is the same thing as you are not going through this week or something

7 0
3 years ago
What software do you sue for design and the rapid prototyping machine?
mash [69]

Answer:

Computer Aided Design (CAD)

Explanation:

For design purpose and rapid prototyping, we use a software known as Computer Aided Design abbreviated as CAD.

Several production formates that are used in CAD are .stp, .stl, .igs, .step where formats like .stp, .igs and .step are used for rapid prototyping and format like .stl is used for design.

The information depending on the extensions used can be modeled in the 3-D files. The most frequent software used for prototyping are: AutoCAD, SolidWorks, SketchUP, etc

This also allows the spatial manipulation, dimension measurement and the visualization of the inner and outer parts.

3 0
4 years ago
thermodynamics A nuclear power plant based on the Rankine cycle operates with a boiling-water reactor to develop net cycle power
IrinaK [193]

Answer:

(a) the percent thermal efficiency is 27.94%

(b) the temperature of the cooling water exiting the condenser is 31.118°C

Explanation:

3 0
3 years ago
Write down everything that you know about climate or climate change.
marta [7]
The Earth's average temperature is about 15C but has been much higher and lower in the past.
There are natural fluctuations in the climate but scientists say temperatures are now rising faster than at many other times.
This is linked to the greenhouse effect, which describes how the Earth's atmosphere traps some of the Sun's energy.
Solar energy radiating back to space from the Earth's surface is absorbed by greenhouse gases and re-emitted in all directions.
This heats both the lower atmosphere and the surface of the planet. Without this effect, the Earth would be about 30C colder and hostile to life.
The greenhouse gas with the greatest impact on warming is water vapour. But it remains in the atmosphere for only a few days.
Carbon dioxide (CO2), however, persists for much longer. It would take hundreds of years for a return to pre-industrial levels and only so much can be soaked up by natural reservoirs such as the oceans.
Most man-made emissions of CO2 come from burning fossil fuels. When carbon-absorbing forests are cut down and left to rot, or burned, that stored carbon is released, contributing to global warming. The world is about one degree Celsius warmer than before widespread industrialisation, according to the World Meteorological Organization (WMO).
It says the past five years, 2015–2019, were the warmest on record.
Across the globe, the average sea level increased by 3.6mm per year between 2005 and 2015.
Most of this change was because water increases in volume as it heats up. However, melting ice is now thought to be the main reason for rising sea levels. Most glaciers in temperate regions of the world are retreating.
And satellite records show a dramatic decline in Arctic sea-ice since 1979. The Greenland Ice Sheet has experienced record melting in recent years.
Warmth shatters section of Greenland ice shelf
Satellite data also shows the West Antarctic Ice Sheet is losing mass. A recent study indicated East Antarctica may also have started to lose mass.
The effects of a changing climate can also be seen in vegetation and land animals. These include earlier flowering and fruiting times for plants and changes in the territories of animals.
The change in the global surface temperature between 1850 and the end of the 21st Century is likely to exceed 1.5C, most simulations suggest.
The WMO says that if the current warming trend continues, temperatures could rise 3-5C by the end of this century.
Temperature rises of 2C had long been regarded as the gateway to dangerous warming. More recently, scientists and policymakers have argued that limiting temperature rises to 1.5C is safer. There is uncertainty about how great the impact of a changing climate will be.
It could cause fresh water shortages, dramatically alter our ability to produce food, and increase the number of deaths from floods, storms and heatwaves. This is because climate change is expected to increase the frequency of extreme weather events - though linking any single event to global warming is complicated. As the world warms, more water evaporates, leading to more moisture in the air. This means many areas will experience more intense rainfall - and in some places snowfall. But the risk of drought in inland areas during hot summers will increase. More flooding is expected from storms and rising sea levels. But there are likely to be very strong regional variations in these patterns. Poorer countries, which are least equipped to deal with rapid change, could suffer the most.
Plant and animal extinctions are predicted as habitats change faster than species can adapt. And the World Health Organization (WHO) has warned that the health of millions could be threatened by increases in malaria, water-borne disease and malnutrition. As more CO2 is released into the atmosphere, uptake of the gas by the oceans increases, causing the water to become more acidic. This could pose major problems for coral reefs.
Global warming will cause further changes that are likely to create further heating. This includes the release of large quantities of methane as permafrost - frozen soil found mainly at high latitudes - melts.
Responding to climate change will be one of the biggest challenges we face this century.
7 0
3 years ago
Suppose you want to buy a new car. The car will be used mainly for going to work, shopping, running errands, and visiting friend
Sergeu [11.5K]
1. So you can complete the things you NEED to do faster. (I.e work, groceries)

2. So it’s easier for you to do leisure activities. (I.e visiting friends, shopping)
5 0
3 years ago
Other questions:
  • A Vector is a quantity that has magnitude, direction, and sense. a)-True b)- False
    12·1 answer
  • 8. Two 40 ft long wires made of differing materials are supported from the ceiling of a testing laboratory. Wire (1) is made of
    7·1 answer
  • Please perform 100 searches on Twitter using keyword "Lebron". Please print out the the number of tweets returned that were in E
    9·1 answer
  • Can someone help me on my auto tech worksheet
    13·1 answer
  • When using bits to represent fractions of a number, can you create all possible fractions? Why or why not?
    6·1 answer
  • A car accelerates from O to 60. miles per hour in 5.2 seconds. Calculate acceleration in m/s seconds. Calculate acceleration in
    15·1 answer
  • Consider a Carnot heat-engine cycle executed in a closed system using 0.028 kg of steam as the working fluid. It is known that t
    11·1 answer
  • Calculate the magnitude of the velocity and the θ angular direction of the block and the bullet together when the 50 g bullet mo
    10·1 answer
  • If the resistance in a series circuit is 12 K Ohms, and the amperage is 0. 0063 amps, what is the voltage?
    15·1 answer
  • As part of its commitment to sustainability, a company is looking for a way to track the source of purchased goods and how they
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!