thadocta
Banned
- Sep 4, 2012
- 5,952
- 1,144
trying to learn so i could eventually make some apps but im struggling through this
1. Open and read the first line of the input file. See LottoNumbers.java included with the Chapter 6 Slideshow for examples on how to do this.
2. Create an integer array named numberArray with 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.”
3. Read the remaining lines of the input file, parsing them as numbers, and assigning them to slots in numberArray.
4. Write a method named sort, which takes numberArray as a parameter and sorts the array from low to high.
5. Once numberArray has been sorted, compute the average of the numbers in the array (not including the count).
6. When sorting is completed and the average has been calculated, open a file named dataout.txt and write the following information to it:
a. The count (number of “slots” in numberArray).
b. The sorted list of numbers in numberArray (one per line).
c. The calculated average of the numbers in the array.
need help on number 4
herees wat i have done so far
public class NumberSorter{
public static void main(String[] args){
int[] intArray = new int[11];
intArray[
= 12345;
intArray[1] = 23456;
intArray[2] = 123;
intArray[3] = 4567;
intArray[4] = 123456;
intArray[5] = 7654;
intArray[6] = 999;
intArray[7] = 3453;
intArray[8] = 997733;
intArray[9] = 43;
intArray[1
=654321;
for (int i=0; i
1. Open and read the first line of the input file. See LottoNumbers.java included with the Chapter 6 Slideshow for examples on how to do this.
2. Create an integer array named numberArray with 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.”
3. Read the remaining lines of the input file, parsing them as numbers, and assigning them to slots in numberArray.
4. Write a method named sort, which takes numberArray as a parameter and sorts the array from low to high.
5. Once numberArray has been sorted, compute the average of the numbers in the array (not including the count).
6. When sorting is completed and the average has been calculated, open a file named dataout.txt and write the following information to it:
a. The count (number of “slots” in numberArray).
b. The sorted list of numbers in numberArray (one per line).
c. The calculated average of the numbers in the array.
need help on number 4
herees wat i have done so far
public class NumberSorter{
public static void main(String[] args){
int[] intArray = new int[11];
intArray[
= 12345;intArray[1] = 23456;
intArray[2] = 123;
intArray[3] = 4567;
intArray[4] = 123456;
intArray[5] = 7654;
intArray[6] = 999;
intArray[7] = 3453;
intArray[8] = 997733;
intArray[9] = 43;
intArray[1
=654321;for (int i=0; i
?