Question
Project 6 Due May 24 by 4:50pm Points 30 Submitting on paper Available after May 8 at 3:30pm Computer Science 111 Introduction to Algorithms and
Project 6
Due May 24 by 4:50pm
Points 30
Submitting on paper
Available after May 8 at 3:30pm
Computer Science 111 Introduction to Algorithms and Programming: Java
Programming Project #6 Arrays, Files, and Sorting (20 points)
Phase 1 - Numbers
Below a list of integer numbers of which the first one will be an exact count of the remaining numbers in the list. So if the first number in the list is 500, there will be 500 additional numbers in the list.
Copy and paste the number data, including the count into a plain text file with the name of the input file given. Your mission, if you choose to accept it, is to write a console program ( NO GUI ). Open and read the first line of this input file and create an integer array with the name of the array given and a size to match the first line of the file. So if the first line of the file contains 500, the array will have 500 slots. Read the remaining numbers into the array. Write a method named sort, which takes the array as a parameter, and sorts it from low to high. When the sort is complete, open and write a file with the name of the output file, the count will be first, followed by the sorted list of numbers (one per line). Finally, write a simple loop to compute the average of the numbers in the list (not including the count). Output this average as the last line of the output file. Be sure to use a double data type for the sum and average variables.
numbers.txt (939 numbers long)
Phase 2 - Strings
Below is a list of Strings of which the first one will be an exact count of the remaining Strings in the list. So if the first string in the list is 200, there will be 200 additional Strings in the list.
Copy and paste the String data, including the count into a plain text file with the name of the input file given. Your mission, if you choose to accept it, is to write a console program ( NO GUI ). Open and read the first line of this input file and create a String array with the name of the array given and a size to match the first line of the file. So if the first line of the file contains 200, the array will have 200 slots. Read the remaining Strings into the array. Write a method named sortstrings, which takes the array as a parameter, and sorts it from low to high. When the sort is complete, open and write a file with the name of the output file, the count will be first, followed by the sorted list of Strings (one per line). Finally, output the String in the middle of the array as the last line of the output file. So if there are 11 slots in the array, the middle item will be in slot 5 of the sorted array. If there are an even number of slots take the lower slot number. So if there are 10 slots in the array, the middle item will be in slot 4 of the sorted array.
inputstrings.txt (array length 212)
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