Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Program Objective: Write a program that takes in two words, and then it recursively determines if the letters of the first word are contained,

Java Program

Objective:

Write a program that takes in two words, and then it recursively determines if the letters of the first word are contained, in any order, in the second word. If the size of the first word is larger than the second then it should automatically return false. Also if both strings are empty then return true.

You May NOT:

Use any iterative loops. In other words, no for-loops, no while-loops, no do-while-loops, no for-each loops.

Use the string method .contains(String)

You May:

Use the string method .charAt(Index)

Hints:

Recursive methods generally attempt to solve a smaller problem then return the results of those in order to solve the larger one.

Think of how to do this with a loop, and use that to guide what parameters youll need for your recursive method.

Example Dialog:

Enter 2 words. I will determine if the letters of one is contained in the other

elf

self

They are contained!

Example Dialog 2:

Enter 2 words. I will determine if the letters of one is contained in the other

jerky

turkey

They are not contained

Example Dialog 3:

Enter 2 words. I will determine if the letters of one is contained in the other

asdf

fasted

They are contained!

image text in transcribed

Write a program that takesonts, sod ben it recursvely determies i the leers of the tisd are coothined, inor, in the second w Ie size of the first word is larger thio the second ber i sbonld automatcally renura tase. Also if both strings eempy tenrue You May NOT Use ay iterative loops Iother ords, ne for-los, no while-oops. no do-while-koaps, no or-eachlo. . Use the string metbod.containsString) You May: so the string merbod .charA'(Indes) . Hints: . Recursive netbods geerally attempt to selve a smaller problea then returat esults of those in order to solve the Ler one. Think of bow to do this with a loop, aud use hat to guide wbat paraetets oa'll oeed fot yourrive etod. Example Dialog: Enter 2 words. I will determine if the letters of one is contained in the other elf self They are contained! Example Dialog 2: Enter 2 words I will determine if the letters of one is contained in the other erky turkey They are not contained Exaaple Dialog 3 Enter 2 words. I will determine if the letters of one is contained in the other asdf Easted They are contained

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

Should standards be used to identify who to blame for problems?

Answered: 1 week ago