Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would this be coded in java not using loops? The goal is below: public boolean validateChar(char ch) This method takes a character, and validates

How would this be coded in java not using loops?

The goal is below:

public boolean validateChar(char ch)

This method takes a character, and validates that it is one of the allowed characters in the input string. It returns true if it is, and false otherwise.

With constraints:

Your code must handle quite a bit of error checking. The strings being passed in must:

  • include only the characters '4', '2' and '_',
  • have exactly a length of three.

If any input string is not formatted according to this, you must return the string, unmodified.

Example Assertions:

assert validateChar('2') : "2 should be a valid char"; assert validateChar('4') : "4 should be a valid char"; assert validateChar('_') : "_ should be a valid char"; assert !validateChar(' ') : "space should not be a valid char"; assert !validateChar('3') : "3 should not be a valid char"; 

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions