SE1011 -- Lab 4: Library Classes

Overview

Write a program that can do a number of different things.

Assignment

Your program must present the user with a menu of three options, numbered 1 to 3. Based on the option selected by the user, the program will do one of three things (described below) and then redisplay the menu. The program will end when the user enters an invalid option.

Option 1: Cats and Dogs

Ask the user to enter a phrase. The program will display the number of "cat" and "dog" character sequences found in the phrase that was entered by the user.

Samples:

Input                                             Output
=====                                             ======
The cat and the dog where friends with dogs.      Cats: 1, Dogs: 1
Cat and cat and dog and doggie dog dog.           Cats: 2, Dogs: 2
dog dog dOg cat DOG cat cat dog                   Cats: 3, Dogs: 5

Option 2: Mix String

Ask the user to enter two words. The program will display a String created from the two words entered by the user. The String is created by taking the first letter from the first word followed by the first letter of the second word. This is repeated for additional letters. If the words entered by the user are not the same length, the leftover characters from the longer word are added at the end of the sequence of alternating characters.

Input                             Output
=====                             ======
Frightfully challenging           Fcrhiaglhltefnuglilnyg
No hope                           Nhoope
Excessively easy                  Eexacseyssively

Option 3: Palindrome

Ask the user to enter a phrase. The program will display one of two messages, based on the phrase entered by the user: "You entered a palindrome." or "You did not enter a palindrome." A palindrome is defined as a phrase that is identical when read from start to finish or finish to start.

Input                             Output
=====                             ======
Monkeys in the make up room       You did not enter a palindrome.
Never odd or even                 You entered a palindrome.
Madam, in Eden I'm Adam           Depends

The third sample depends on whether the program ignores punctuation or not. The program is not required to ignore punctuation; however, you may add the feature if you wish.

Requirements

  • The program must be created in a class named Lab4 that is in a package named the same as your MSOE username.
  • The program may use console or windowed input/output.
  • You must use a switch statement to manage the program menu.

Lab Deliverables

Demonstration (due at the end of week 5 lab)

Each student must demostrate a partially complete version of their program to their instructor. The program must:

  • Have complete menu functionality (just display a message for the uncomplete menu selections) (-10 points if not completed)
  • Option 1 (-10 points if not completed)
  • Option 2 (-5 points if not completed)

Submission (due at 11pm the day of week 5 lab)

Each student must submit their program with complete functionality. The program must contain comments at the beginning of the file that include: Course name, Quarter, Assignment name, Author's name, and date (see here). Student's must use the electronic submission form to submit their code.

Enter your MSOE username for the username, select "Lab 4" for the assignment, select your Lab4.java implementation for the report file name and leave the support file name blank.

Acknowledgment

This laboratory assignment was developed by Dr. Chris Taylor.

  • © 2001-2009 Dr. Christopher C. Taylor •
  • Office: L-343 •
  • Phone: 277-7339 •
  • npǝ˙ǝosɯ@ɹolʎɐʇ