Question: Please help me with this portion of the code, I'm having trouble inserting my Numbers.txt Task #3 Writing Output to a File 1. Copy the

Please help me with this portion of the code, I'm having troubleinserting my Numbers.txt Task #3 Writing Output to a File 1. CopyPlease help me with this portion of the code, I'm having trouble inserting my Numbers.txt

Task #3 Writing Output to a File 1. Copy the files Stars Demo jawe soc Code Listing 4.2) and Nimbers.tot from the Student CD ar as directed by your instructor. 2. First we will write output to a file 2. Create a Filewriter object passing it the filename Results.but (Don't forget the needed import statement). h. Create a Print Writer object passing it the FileWriter object. Since you are using a Filewriter object, add a throus clause to the main method header d. Print the mean and standard deviation to the output file using a three decimal format, labeling cach. e. Close the output file. 3. Compile, debug, and run. You will need to type in the filename Numhers.ext. You should get no output to the console, but running the program will create a file called Results with your output. The output you should get at this point is mean -0.000, standard deviation - 0.000. This is not the correct mean or standard deviation for the data, but we will fix this in the next tasks. Task #4 Calculating the Mean 1. Now we need to add lines to allow us to read from the input file and calculate the mean. 2. Create a FilaReader object passing it the filename. h. Create a BufferedReader object passing it the FileReader object. 2. Write a priming read to read the first line of the file. 3. Write a loop that continues until you are at the end of the file. 4. The body of the loop will: 2. convert the line into a double value and add the value to the accumulator b. increment the counter . read a new line from the file 5. When the program exits the loop close the input file. & Calculate and store the mean. The mean is calculated by dividing the accumulator by the counter 7. Compile, debug, and run. You should now get a mean of 77.444, but the standard deviation will still be 0.000 Task #5 Calculating the Standard Deviation 1. We need to reconnect to the file so we can start reading from the top again. * Create a FileReader object passing it the filename b. Create a BufferedReader object passing it the FileReader object. 2. Reinitialize the sum and count to 0. 3. Write a priming read to read the first line of the file. Copyright 2016 Pearson Education, Inc., Hoboken NJ 4. Write a loop that continues until you are at the end of the file. 5. The body of the loop will: a. convert the line into a double value and subtract the mean, store the result in difference b. add the square of the difference to the accumulator c. increment the counter d read a newline from the file. 6. When the program exits the loop close the input file. 7. The variance is calculated by dividing the accumulator (sum of the squares of the difference) by the counter. Calculate the standard deviation by taking the square root of the variance (Use the Math.sgt method to take the square root) 8. Compile, debug, and run. You should get a mean of 77.444 and standard deviation of 10.021

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!