Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For Java Create a program that asks the user to enter a monogram. Monograms are always 3 characters long and represent someones first initial, last
For Java Create a program that asks the user to enter a monogram. Monograms are always 3 characters long and represent someones first initial, last initial, and middle initial. Valid monograms always contain letters (not numbers or special characters).
Store the information entered by the user as a String. Then test to determine whether the user input is a valid monogram using the following criteria.
If the user information does not contain 3 characters, display a message saying that the monogram does not contain 3 characters. (HINT: Review your notes called Using Strings (and other objects) for information on how to find the length of a String.)
If the user information contains 3 characters, display a message saying that the monogram has the correct length.
If the monogram has a valid length, consider the characters within the monogram. (HINT: Review your notes called Using Strings (and other objects) for information on how to consider a single character within a String.) Use the isLetter() method of the Character class to test to see if the characters in the monogram are all letters. If they are, display a message saying that the monogram is valid.
Heres an example of how to call this method:
char ch = a;
boolean result = Character.isLetter(ch);
If the 3 characters arent all letters, display a message saying that the monogram must contain only characters.
Here are some samples of input/output from the program. User input is shown in orange.
Enter your 3 character monogram ABC Your input contains exactly 3 characters. ABC is a valid monogram
Enter your 3 character monogram ABCDEFG Monograms must contain exactly 3 characters. You entered: ABCDEFG
Enter your 3 character monogram A9B You input contains exactly 3 characters.
Monograms only contain letters! You entered: A9B
Enter your 3 character monogram 1BC Your input contains exactly 3 characters. Monograms only contain letters! You entered: 1BC
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