Description
1. Random Binary Files (5 marks)Write a program that will write 100 randomly
generated integers to a binary file using the writeInt(int) method in
DataOutputStream. Close the file. Open the file using a DataInputStream. Read the
integer values as if the file contained an unspecified number (ignore the fact that
you wrote the file) and report the sum and average of the numbers. Please submit
the one java file for this part.
2. Text File Game (15 marks) Write a program that will ask the user for their name and
then ask them to answer at least 5 multiple choice questions. The questions should
all live in a file called questions.txt the file should look similar to the one below:
Q1) How tall is the CN Tower?
1)1000m
2)553m
3)1m
4)100m
2
Q2) What Is the Airspeed Velocity of an Unladen Swallow?
1) …
Which will contain both the questions, the choices and the right answer. Your program will
keep asking the user questions so long as there is more in the file and keep track of if the user
got it right or wrong in a score variable. When the input file is out of questions and has gotten
the last answer from the user it should tell the user their score and APPEND their score in a
scores.txt file. The scores.txt file will record the users name and score. After the game is over it
should show the users score along with other users who have played the game scores.
You are expected to submit both your .java file and a file called questions.txt containing your
questions (note: this is a good thing because it means you can structure them any way you
want)