Question: dat structun m manipulate arrays is an important skill. In this assignment, we'l review arra andom values then manually merge the arrays in Arrays were
dat structun m manipulate arrays is an important skill. In this assignment, we'l review arra andom values then manually merge the arrays in Arrays were the first by filling two arrays with to one new array. Finally, to review files, the assignment includes a simple writing to and reading from a file. Specifications . If using Eclipse, create a Java project called CS1450 gnment1 2. Create a Java class within that project called LastNameFirstNameAssi Please use this naming convention. For example, I would name my file GonzalezMickeyAssignment1 a. b. . Follow "CS1450 Programming Assignments Policy See the Canvas document Review: Files for additional help with files For this assignment, everything can be in main)-that is-methods and classes are not required . . 5. Step 1: perform the following file-based tasks: a. In your code create a file named assignment1.bxft. i. Do not include any path names in your code when creating the file. ii. That is, use only the relative filename assignment1.txt so the file will be placed in your current working directory. This makes the grader's life a lot easier! b. After the file is created and opened for writing, generate and display two random numbers- size1 and size2- between 1 and 15 Generate size1+size2 random integers between 0 and 99 and write them to the file Display each value as it is written to the file. i. These values size1 and size2 will be used in step 2 as the size of each array. c. i. Write one value on each line in the file d. Step2: perform the following array processing tasks: a. Reopen the file for reading b. Read size1 values from the file and place into an array. c. Read remaining size2 values from the file and place into another array d. Sort both arrays using the sort method in the Arrays class e. Merge the two arrays into one sorted array WITHOUT using the sort method Manually go through the arrays and determine which value to transfer to merged array i. i. Keep in mind that the placement of allvalues in one array could occur before all values in 2nd array. This is, one array will be done before the other. f. Display merged array after manually sorting. Notes and Tips The assignment1.txt file will be overwritten each time your code is run. Must Do You must use an array, not an array list. You must write code to manually merge the arrays and create a sorted merged array. e Must Not Do Do not include path names for the file. Use only assignment1.txt Do not use the sort method to sort the merged array . Tip Merging two arrays manually requires two steps: First, use a while loop to move values from the arrays in sorted order into the merged a o This while loop will terate until all values in one of the arrays have been moved. Second,after the while loop, determine which array still contains values and move those value while (nore values in Array1) / Move remaining values in arrayl to merged list while (more values in Array2) // Move renaining values in array2 to nerged list Output Your output will look like the following except with different random numbers. size1 7 size2 11 Generate 18 random values and write to a file 15 28 71 18 37 62 67 25 46 35 35 54 24 se Read 7 values from file and placing into the 1st array Read 11 values fron file and placing inte the 1i Random values stored in order in merged array 15 35 37 62 71
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
