Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java program Western Canada has decided to form a navy consisting of Carriers (CV), Battleships (BB), and Destroyers (DD). The naming of the ships in

java program

Western Canada has decided to form a navy consisting of Carriers (CV), Battleships (BB), and Destroyers (DD). The naming of the ships in this new navy is to follow these rules.

  • All ship names are to begin with HMWC (Her Majestys Western Canadian).
  • Carrier Names start with HMWCCV and have a 3-digit value after them that is evenly divisible by 100 (i.e. HMWCCV100, HMWCCV200 are valid, HMWCCV150 is not).
  • Battleships names begin with HMWCBB and have a 2 digit value after them that is evenly divisible by 10 (i.e., HMWCBB10 and HMWCBB30 are valid, HMWCBB15 is not)
  • Destroyer names with begin with MHWCDD and have Single Letter in the range A to G (i.e. HMWCDDD, HMWCDDE are valid, HMWCDDM is not).

Complete the method stub in Q2 call isValidName to use a Regular expression to determine if the given name is a valid ship name by the rules described above.

this is what i have

package mid1;

public class Q2 { public static boolean isValidName(String sName) { //Replace the following with required implementation to fufill Q2 in the mid1 return false; }

}

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

Students also viewed these Databases questions