Question
The first task has you building a method that will check whether a message's characters (after any lowercase letters have been changed to be uppercase
"The first task has you building a method that will check whether a message's characters (after any lowercase letters have been changed to be uppercase letters) are all in the valid range (ASCII 32 to 93). This will allow you to practice using a for loop to iterate through the characters of a String and using Java operators to have your code interact with individual characters. There is one method to implement for this task:
public static booleansafeToUse(String plaintext)
The parameter plaintext will refer to a String object. Your code will need to iterate through this character by character and make sure each one is valid to be used in our coding schemes. If any of the characters are outside the valid range, then the method returns false. Recall from about that the range of valid characters for this project doesn't contain any lowercase letters. This means that the first thing we'll probably want to do to the plaintext is convert it to uppercase-only. You should find the .toUpperCase method that all String objects can invoke quite useful here!
Once you have an uppercase-only version of the message, use a for loop and something like the .charAt(position) method that can be invoked by any String object to iterate through the message character by character. As you visit each character, make sure that its ASCII value isn't outside of the valid range. Note that in the provided starter code, we've provided some static constants:
static final char FIRST = ' ';
static final char LAST = ']';
static final int RANGE = last-first+1;
You might find these useful as you develop your code for this project, either in this task or in others."
Step by Step Solution
3.52 Rating (159 Votes )
There are 3 Steps involved in it
Step: 1
PlainTextTestjava public class PlainTextTest static final char FIRST static final char LAST static ...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