Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Complete the recursive method match(String x, String y) in the code below which will determine whether or not two strings match.  The matching process should allow "wild cards". A '@' character will match with any other single character and a '*' character will match with 0 or more characters of any type.

public class CompareStrings {

  public static boolean match(String x, String y) {

  ... ;

 }

  public static void main(String args[]) {
  System.out.println(match("hello", "hello."));  // should return false
  System.out.println(match("hello", "jello"));  // should return false
  System.out.println(match("hello", "h@llo"));  // should return true
  System.out.println(match("hello", "h@@@@"));  // should return true
  System.out.println(match("hello", "h*"));  // should return true
  System.out.println(match("hello", "*l*"));  // should return true
  System.out.println(match("anyString", "*"));  // should return true
  System.out.println(match("help", "h@@@@"));  // should return false
  System.out.println(match("help", "h*"));   // should return true
  System.out.println(match("help", "*l*"));  // should return true
  System.out.println(match("help", "*l*p"));  // should return true
  System.out.println(match("help", "h@llo"));  // should return false
  System.out.println(match("", "*"));     // should return true
  System.out.println(match("", "***"));   // should return true
  System.out.println(match("", "@"));     // should return false
 }
}
 
As a hint, try to first get your code working without wild cards. Then get it working with the '@' character and lastly with the '*' character. Remember to break the Strings apart one letter at a time and that the recursive call should take one or two smaller strings as parameters.

Java, Programming

  • Category:- Java
  • Reference No.:- M9716246
  • Price:- $15

Priced at Now at $15, Verified Solution

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As