Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(In Java)Project 1: Reading and writing primitives In this project, you will read and write numbers from and to a binary file, first using output
(In Java)Project 1: Reading and writing primitives
In this project, you will read and write numbers from and to a binary file, first using output and input streams, then using a random-access file
Step 1: Using an ObjectOutputStream:
- Delete any existing file(s) left over from prior runs.
- Open, then write 10 randomly-generated numbers with values between 1 and 10 onto the file, then close the file.
- Open the file using an ObjectInputStream and read the numbers into an array of the appropriate data type.
- Write a method which takes as a parameter an array of numbers of the data type you are using. This method should sort the array in ascending order using a Selection, Insertion, or Bubble sort algorithm, again your choice. Invoke this method on the array of numbers (putting them in ascending order).
Do not use any sort method provided by Java (e.g., Arrays.sort()
- Once sorted, display the 10 numbers on the console in sorted order.
Step 2: Do the same thing using a Random Access file.
- In this step, do not close and then reopen the file. Instead, just reset the file pointer back to the beginning of the file after writing the 10 random numbers.
Submit a listing of your program and a PrintScreen showing the output of both steps above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started