Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. This is a continuation of Exercise 1 from week 7 practical exercises. Import a copy of NumberFile.java (from week 7) into your week 8

image text in transcribed

1. This is a continuation of Exercise 1 from week 7 practical exercises. Import a copy of NumberFile.java (from week 7) into your week 8 project in Eclipse. Modify your solution code as follows: a. Modify the second method (the method that reads the data from the file into memory) so that the data is read from the file into an array of appropriate data type. Assume that the array can store a maximum of 5000 numbers. Your method will need to ensure that a maximum of 5000 numbers are read from the file even if there are more than 5000 values in the file. You cannot assume that there will always be 5000 values in the file. The method should no longer display the values to the screen. b. Modify the third method (the method that numerically added the values from the file) so that the sum is calculated from the array that was created in part a above. The method will need to return the sum. Display the total (sum) in your main program. C. Add a new method to calculate and return the average (mean) of the values in the array. Display the average in your main program d. Add a new method to display the contents of the array. Consider that the logical end of the array may not be the physical end of the array. e. Your program must allow the user to choose if they want to create the file, read the file content into an array, calculate and display the total from the array, calculate and display the average of the array content, display the array content, or exit the program. The program should continue to run until the user chooses to exit the program. f. As per part b of exercise 1 in week 7 your program should i. allow the user to choose the starting and ending values to be stored in the file, ii. enter the file name of the file to be created, ii. and enter the file name for the file to be read by the program. Test the program with different sized files with different sets of numbers. Make sure your code works correctly if the file isn't found, if it exists but doesn't have any data in it, or, if the file has too many values to fit into the array. Your solution must incorporate appropriate methods utlising appropriate parameter passing. 1. This is a continuation of Exercise 1 from week 7 practical exercises. Import a copy of NumberFile.java (from week 7) into your week 8 project in Eclipse. Modify your solution code as follows: a. Modify the second method (the method that reads the data from the file into memory) so that the data is read from the file into an array of appropriate data type. Assume that the array can store a maximum of 5000 numbers. Your method will need to ensure that a maximum of 5000 numbers are read from the file even if there are more than 5000 values in the file. You cannot assume that there will always be 5000 values in the file. The method should no longer display the values to the screen. b. Modify the third method (the method that numerically added the values from the file) so that the sum is calculated from the array that was created in part a above. The method will need to return the sum. Display the total (sum) in your main program. C. Add a new method to calculate and return the average (mean) of the values in the array. Display the average in your main program d. Add a new method to display the contents of the array. Consider that the logical end of the array may not be the physical end of the array. e. Your program must allow the user to choose if they want to create the file, read the file content into an array, calculate and display the total from the array, calculate and display the average of the array content, display the array content, or exit the program. The program should continue to run until the user chooses to exit the program. f. As per part b of exercise 1 in week 7 your program should i. allow the user to choose the starting and ending values to be stored in the file, ii. enter the file name of the file to be created, ii. and enter the file name for the file to be read by the program. Test the program with different sized files with different sets of numbers. Make sure your code works correctly if the file isn't found, if it exists but doesn't have any data in it, or, if the file has too many values to fit into the array. Your solution must incorporate appropriate methods utlising appropriate parameter passing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions