L01

Due by the end of this meeting


SUBMIT   /   Submission Summary

Words (Review of Arrays, Loops, Methods and Conditionals)

Synopsis

Write a program Lab01 to read in multiple words and then redisplay them based on their length. The user is prompted whether they want to show words that are longer, shorter, or equal to a length they provide. The activity continues until the user asks to quit.

Details

Write a program that behaves as follows:

  1. It prompts for and reads the number of words the user has.
  2. It prompts for and reads that many words.
  3. It repeats the following until the user chooses the quit option:
    1. It prompts for a command from long, short, equal and quit.
    2. For each of the long/short/equal options it prompts for the length, then reports the appropriate words one per line.
    3. For unknown options it prints an error message.

Other requirements:

The following are examples of running the Lab01 program for L01. Text in blue shows where the user enters input, with the showing where the user presses the enter key.

How many words do you have? 10 Enter them below: one two three four five six seven eight nine ten Enter your choice: Long, Short, Equal or Quit? Long How long is the shortest word to show? 5 Here are the words: - three - seven - eight Enter your choice: Long, Short, Equal or Quit? short How long is the longest word to show? 3 Here are the words: - one - two - six - ten Enter your choice: Long, Short, Equal or Quit? equal How long should the words be? 4 Here are the words: - four - five - nine Enter your choice: Long, Short, Equal or Quit? quit
How many words do you have? 5 Enter them below: nonmonotonic reasoning is nonclassical logic Enter your choice: Long, Short, Equal or Quit? short How long is the longest word to show? 5 Here are the words: - is - logic Enter your choice: Long, Short, Equal or Quit? EQUAL How long should the words be? 10 Here are the words: Enter your choice: Long, Short, Equal or Quit? what? I don't recognize that command! Enter your choice: Long, Short, Equal or Quit? long How long is the shortest word to show? 10 Here are the words: - nonmonotonic - nonclassical Enter your choice: Long, Short, Equal or Quit? quit

Submit this/these files:


SUBMIT   /   Submission Summary