Labs

For this lab we will accept user input and use information about the ASCII characters.

  1. Write a program to prompt the user for a String and check if the String meets certain conditions.
  2. Use Scanner.nextLine() to read in a String that may contain spaces.
  3. Check if all characters in an input String are letters (upper or lower) and print a messaging saying the result.
  4. Some String methods you might use:
    • stringInstance.length() - get the length of the String.
    • stringInstance.charAt(i) - get the char at index i, which starts at 0 (like an array index).

(Solution: AlphaNumCheck.java)

  1. Modify the program in (1) to see if the characters are alphanumeric (letters and numbers) or the space character.

(Solution: AlphaNumCheck2.java)


Prev -- Up