Starting from:

$25

Assignment #2 Using set and list.

Programming Assignment #2

This assignment focuses on using set and list. Choose only one of the problems. (20points)
1. Write a Java program that outputs a list of students from the given data file. Download the data file
(student.txt) from our web site to the same folder as your program. You have to use input.hasNext()
with while loop when your program reads tokens from the file. We are assuming that you don’t know
how many lines in the data file. The file contains class code followed by student name. You are required to
use HashSet for this program. Your program outputs the student’s name who
1. takes CS211 or CS210
2. takes CS211 and CS210
3. takes CS211 but not CS210
4. takes CS210 but not CS211.
2. Download the data file (fruit.txt) from our web site to the same folder as your program. The file contains
name of fruits. You may use ArryList to save the data into your memory. Your program choose one of
the fruits using random method, then outputs the selected fruit name after using
Collections.shuffle. User can answer the exact name of the fruit. You are required to use
Collections.shuffle for this program. This is a kind of puzzle game. For this assignment, you don’t
need to check whether the answer is collect or not.
Your program might produce the following output:
R G E N A O
Orange
G P A R E
Grape
N A A N A B
Banana
.

More products