CS 212 M5 Assignments
1. Based on the integer
List
class in the Lecture Notes, write a driver to read 7 integers, and store them into a predefined object
myList
(shown below), sort the list into ascending order and output the list to the monitor. Then sort the list into descending order, and output the list to the monitor.
List myList = new List();
Hint: refer to #3 of M5 Code Examples.
2. Based on the
FractionList
class in the Lecture Notes, write a driver to read 5 fraction numbers, and store them into a predefined object
fList
(shown below), sort the list into ascending order and output the list to the monitor. Then sort the list into descending order, and output the list to the monitor.
FractionList fList = new FractionList();
Hint: refer to #5 of M5 Code Examples.
3. Based on the
StrList
class in the Lecture Notes, modify it if needed and then write a driver to prompt the following menu and let the user choose an operation and then perform the corresponding operation. Use a loop, so the code could run continuously.
(Bonus of 10 points) To receive the extra credits, the name should be a full name (with or without middle names) and the list should be displayed in a column.
I Insert a name
A Sort the name list to ascending order
D Sort the name list to descending order
F Find if a name on the list
P Print the name list
N Display the size of the name list (Number of names)
Q Quit