Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started