Assignment 8
Due Thursday, February 8 at 11:20am on Canvas


Assignment 8.1: A Long Name? (10 pts)
  • Write a program to read in a user's name and report back whether their name is a long name.
  • Trivia: The average name length in the United States is about 6 letters long.
  • We will consider a long name to be more than 6 letters.
  • Important: You are required to use exactly one if and one else in this program for full credit. No else if statements!
  • Name your file Long.java.
  • The program should work identically to the code below:

Please enter your first name: Jennifer
Jennifer is a long name!

Alternately,

Please enter your first name: Rosco
Rosco is not a long name.

Alternately,

Please enter your first name: Bo
    Bo is not a long name.


Assignment 8.2: Student ID Numbers (10 pts)

  • Open a new Java project in Eclipse called StudentID with a class named StudentID.java
  • Your program should prompt a user to enter a student ID number as a series of numbers.
  • It will check whether the user entered a valid 8-digit de Anza student ID number and report an error message if the ID number entered is too short or too long (no other error checking is required).
  • It will then display the ID number in the format XXX-XXX-XX
  • Your program should work identically to these examples (except user input will vary):

Please enter your 8 digit student ID number: 203456
Sorry! That ID is invalid.
Please run the program again.
  • Alternately:

Please enter your 8 digit student ID number: 1034566330
Sorry! That ID is invalid.
Please run the program again.

  • Alternately,
Please enter your 8 digit student ID number: 20456855
You entered: 204-568-55
  • Hint: Use Strings, not ints. And, make use of the String methods we discussed in class under Lesson 7.
  • Important: You are required to use exactly one if and one else for full credit. Do not use else if for this assignment!
  • Submit StudentID.java to Canvas when you are finished.