15-100: Introductory/Intermediate Programming (Section F)
Fall 2006
Exercise    - practice
11/28/2006
Practice Arrays
Due:  none

Relevant Reading:

  • Readings on Arrays in Head First Java:
    • Pgs 17-19
    • Chapter 3, starting at page 59
    • Pg 83
  • Notes taken in class.

Assignment:  (worth 0 exercise points - this exercise is for practice only)  THIS EXERCISE IS FOR PRACTICE ONLY.  SEE SCOTT OR A COURSE ASSISTANT IF YOU HAVE PROBLEMS OR QUESTIONS.

1) HINT:  Look at the compareTo method in the String class.

 a)  Write a program that:
  • asks the user for 20 people's names.  (Store them in an array.)
  • ask the user for another name (I'll call it NAME).
  • give a listing of all people entered who come before NAME in alphabetical order.  List them in the SAME order that they were typed in.
  • give a listing of all people entered who come after NAME in alphabetical order.  List them in the SAME order that they were typed in.
  • give a listing of all of the names in alphabetical order.
You may assume that people's names are entered such as follows to facilitate alphabetical ordering.  
Smith, Jane
Doe, John

b:
Write a second program that lets the user type in names such as Jane Smith and John Doe, but your program still determines alphabetical ordering by LAST name.  


2)
  Write a program which allows the user to enter a list of course percentages (0 - 100).   Your program should handle as many scores as the user wishes to enter.  
After all grades have been entered, display all of the grades which were each of the letter grades. For instance:
Sample Input:    100  90  80  81  78  73 95  55
Sample Output:
A    100  90  95
B    80  81
C    78  73
D   
F    55


3)  Ask the user to type in the name of 10 movies.  Afterwards, the program should display the movies, with every second movie all capitalized.  EG:
Meet the Fockers
THE PHANTOM OF THE OPERA
The Wizard of Oz
SINGING IN THE RAIN
Shrek
SAHARA
Fever Pitch
THE PACIFIER
Spanglish
FINDING NEVERLAND


4)  Write a program that creates 25 robots placed in random positions on the screen.

a) Ask the user how many times each robot should move.  Then, have each robot move that many times.

b)  Before each robot moves, have it turnLeft a random number of times.  (Eg. robot 0 turns 2 twice then moves, robot 1 turns 5 times then moves, etc.)


5)  Write a program that asks the user to enter 30 numbers.  The program then reports how many of them were odd, and how many were even.  THEN, the program lists WHICH numbers were odd.

6)  Using the NewsTeam class we have looked at in class.....

a)  Write a program that asks the user for the name and experience of each of 15 people.  The program should then hire all of these people and assign them roles on the news.  When done, the program should display all of the team members.

b)  Have the newsteam members shuffle offices such that they are in order of the number of years of experience that they have.

c)  Have the newsteam members shuffle offices such that they are in alphabetical order.

d)   Move all of the "Weather" people to the front of the array, and everyone else back.

e)  Have the program change all "Weather" people to "Meterology".

7)  Get the ex-filters.zip file.  In this project, you will find a StringList class and a StringListTester class.  Your job is to finish the StringList class so that the StringListTester class works.  (IE. don't modify the StringListTester class.)

In particular, you need to fill in three methods.  If you have any questions about how any of these functions should work, ask.  You should not need to modify anything but the contents of those three methods.
Be sure to test your program on all five sample input files (words1,words2,words3, words4, and words5).  The output should make sense to you.

For a working program, your output for words1.txt would look something like this:

enter file name: words1.txt
Here are the strings:
January,February,March,April,May,June,July,August,September,October,November,December,
---
Here are the strings of length less than 10:
January,February,March,April,May,June,July,August,September,October,November,December,
---
Here are the strings of length less than 5:
May,June,July,
---
Here are the strings of length less than 1:


Please hit enter:
-------------
Here are the strings shorter than holiday:
March,April,May,June,July,August,
---
Here are the strings shorter than Rumpelstiltskin:
January,February,March,April,May,June,July,August,September,October,November,December,
---
Here are the strings shorter than mom:

Please hit enter:
-------------
Here are the strings that come before holiday:
January,February,March,April,May,June,July,August,September,October,November,December,
---
Here are the strings
that come before Rumpelstiltskin:
January,February,March,April,May,June,July,August,October,November,December,
---
Here are the strings
that come before mom:
January,February,March,April,May,June,July,August,September,October,November,December,

Please hit enter:
-------------
Deleted strings longer than 10.
Here are the strings:
January,February,March,April,May,June,July,August,September,October,November,December,
---
Deleted strings longer than 5.
Here are the strings:
March,April,May,June,July,
---
Deleted strings longer than 1.
Here are the strings:

---
Deleted strings longer than 5.
Here are the strings:

For the rest of the sample files, you will have to decide for yourself what the correct output should be.


Handin:
  • None.