Complete the following exercises using the Eclipse IDE to produce working Java code. Coding Standards: When...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Complete the following exercises using the Eclipse IDE to produce working Java code. Coding Standards: When writing code in this unit you are required to adhere to the Coding Standards and General Principles as defined in the FAQ in VUWS. 1. Class name: NumberArray.java This is a modification of Exercise 1(i) from week 7 practical exercises to incorporate the use of arrays to store the data from the file. Create a week 9 project. Import a copy of ReadNumberFile1.java into your week 9 project in Eclipse. Rename ReadNumberFile1.java to NumberArray.java. Modify your NumberArray.java code as follows: Write a method that reads the data from the file into an array (do not use an arraylist) of appropriate data type. Set the size of the array to 100 elements; hence the array can store a maximum of 100 numbers. Your method will need to ensure that a maximum of 100 numbers are read from the file even if there are more than 100 values in a. b. C. d. e. f. the file. You cannot assume that there will always be 100 values in the file (there may be more, there may be less). The method should return the array and the count of numbers stored in the array. Write a method to calculate the sum (total) of all values in the array that was created in part a above. The method will need to return the sum. Consider that the logical end of the array may not be the physic end of the array. Write a method to calculate and return the average (mean) of the values in the array. Consider that the logical end of the array may not be the physical end of the array. Write a method to output the contents of the array to the screen, one value per line of output. Consider that the logical end of the array may not be the physical end of the array. Write a method to output the contents of the array to a file named numbersoutput.txt, one value per line of output. Consider that the logical end of the array may not be the physical end of the array. Your program must firstly read the file into the array by calling the method you wrote in part a above, then allow the user to choose if they want to read the file content into an array, display the sum of the array values, display the average of the array values, display the array content, create the output file, or exit the program. The program should continue to run until the user chooses to exit the program. Test the program with different sized input files with different sets of numbers (several files have been provided in the zip file). 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 and must not use arraylists. During the Week 7 practical complete the following exercises using the Eclipse IDE to produce working Java code. Coding Standards: When writing code in this unit you are required to adhere to the Coding Standards and General Principles as defined in the FAQ in vUWS. Your code for the following exercises should adopt these standards and general principles. 1) a) Create a week 7 Java project. Eight text files have been provided in the week 7 practical zip file. Copy the eight text files into the root folder of the project. In the exercises below you will write java code to read the data from these text files. The code will be very similar for each program. Do not use arrays or arraylists in any of these programs. There are several example files in the week 6 lecture which will assist with several aspects of this question. i) ii) The numbers.txt file consists of multiple whole numbers, one number per line. Write a java program named ReadNumberFile1.java that reads the data from numbers.txt and displays the data to the screen (one number per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that only whole numbers will be in the file). Test that your code works correctly by running the program using numbers1.txt, numbers2.txt, and numbers99.txt as the input file. The numbers3.txt file consists of multiple whole numbers, two numbers per line separated by a space. Write a java program named ReadNumberFile2.java that reads the data from numbers3.txt and displays the data to the screen (two numbers per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that only whole numbers will be in the file). Test that your code works correctly by running the program using numbers3.txt, numbers4.txt, and numbers99.txt as the input file. iii) The numbers5.txt file consists of multiple whole numbers, three numbers per line separated by a space. Write a java program named ReadNumberFile3.java that reads the data from numbers5.txt and displays the data to the screen (three numbers per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that only whole numbers will be in the file). Test that your code works correctly by running the program using numbers5.txt, and numbers99.txt as the input file. iv) The numbers6.txt file consists of multiple whole numbers and floating-point numbers, three numbers per line (in the order whole number, floating point number, whole number) separated by a space. Write a java program named ReadNumberFile4.java that reads the data from numbers6.txt and displays the data to the screen (three numbers per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that the first and third number on every line is a whole number, and that the second number on every line is a floating-point number). Test that your code works correctly by running the program using numbers6.txt, and numbers99.txt as the input file. v) The numbers7.txt file consists of multiple whole numbers and strings, three values per line (in the order whole number, string, whole number) separated by a space. Write a java program named ReadNumberFile4.java that reads the data from numbers7.txt and displays the data to the screen (three values per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that the first and third number on every line is a whole number, and that the second value on every line is a string). Test that your code works correctly by running the program using numbers7.txt, and numbers99.txt as the input file. Complete the following exercises using the Eclipse IDE to produce working Java code. Coding Standards: When writing code in this unit you are required to adhere to the Coding Standards and General Principles as defined in the FAQ in VUWS. 1. Class name: NumberArray.java This is a modification of Exercise 1(i) from week 7 practical exercises to incorporate the use of arrays to store the data from the file. Create a week 9 project. Import a copy of ReadNumberFile1.java into your week 9 project in Eclipse. Rename ReadNumberFile1.java to NumberArray.java. Modify your NumberArray.java code as follows: Write a method that reads the data from the file into an array (do not use an arraylist) of appropriate data type. Set the size of the array to 100 elements; hence the array can store a maximum of 100 numbers. Your method will need to ensure that a maximum of 100 numbers are read from the file even if there are more than 100 values in a. b. C. d. e. f. the file. You cannot assume that there will always be 100 values in the file (there may be more, there may be less). The method should return the array and the count of numbers stored in the array. Write a method to calculate the sum (total) of all values in the array that was created in part a above. The method will need to return the sum. Consider that the logical end of the array may not be the physic end of the array. Write a method to calculate and return the average (mean) of the values in the array. Consider that the logical end of the array may not be the physical end of the array. Write a method to output the contents of the array to the screen, one value per line of output. Consider that the logical end of the array may not be the physical end of the array. Write a method to output the contents of the array to a file named numbersoutput.txt, one value per line of output. Consider that the logical end of the array may not be the physical end of the array. Your program must firstly read the file into the array by calling the method you wrote in part a above, then allow the user to choose if they want to read the file content into an array, display the sum of the array values, display the average of the array values, display the array content, create the output file, or exit the program. The program should continue to run until the user chooses to exit the program. Test the program with different sized input files with different sets of numbers (several files have been provided in the zip file). 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 and must not use arraylists. Complete the following exercises using the Eclipse IDE to produce working Java code. Coding Standards: When writing code in this unit you are required to adhere to the Coding Standards and General Principles as defined in the FAQ in VUWS. 1. Class name: NumberArray.java This is a modification of Exercise 1(i) from week 7 practical exercises to incorporate the use of arrays to store the data from the file. Create a week 9 project. Import a copy of ReadNumberFile1.java into your week 9 project in Eclipse. Rename ReadNumberFile1.java to NumberArray.java. Modify your NumberArray.java code as follows: Write a method that reads the data from the file into an array (do not use an arraylist) of appropriate data type. Set the size of the array to 100 elements; hence the array can store a maximum of 100 numbers. Your method will need to ensure that a maximum of 100 numbers are read from the file even if there are more than 100 values in a. b. C. d. e. f. the file. You cannot assume that there will always be 100 values in the file (there may be more, there may be less). The method should return the array and the count of numbers stored in the array. Write a method to calculate the sum (total) of all values in the array that was created in part a above. The method will need to return the sum. Consider that the logical end of the array may not be the physic end of the array. Write a method to calculate and return the average (mean) of the values in the array. Consider that the logical end of the array may not be the physical end of the array. Write a method to output the contents of the array to the screen, one value per line of output. Consider that the logical end of the array may not be the physical end of the array. Write a method to output the contents of the array to a file named numbersoutput.txt, one value per line of output. Consider that the logical end of the array may not be the physical end of the array. Your program must firstly read the file into the array by calling the method you wrote in part a above, then allow the user to choose if they want to read the file content into an array, display the sum of the array values, display the average of the array values, display the array content, create the output file, or exit the program. The program should continue to run until the user chooses to exit the program. Test the program with different sized input files with different sets of numbers (several files have been provided in the zip file). 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 and must not use arraylists. During the Week 7 practical complete the following exercises using the Eclipse IDE to produce working Java code. Coding Standards: When writing code in this unit you are required to adhere to the Coding Standards and General Principles as defined in the FAQ in vUWS. Your code for the following exercises should adopt these standards and general principles. 1) a) Create a week 7 Java project. Eight text files have been provided in the week 7 practical zip file. Copy the eight text files into the root folder of the project. In the exercises below you will write java code to read the data from these text files. The code will be very similar for each program. Do not use arrays or arraylists in any of these programs. There are several example files in the week 6 lecture which will assist with several aspects of this question. i) ii) The numbers.txt file consists of multiple whole numbers, one number per line. Write a java program named ReadNumberFile1.java that reads the data from numbers.txt and displays the data to the screen (one number per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that only whole numbers will be in the file). Test that your code works correctly by running the program using numbers1.txt, numbers2.txt, and numbers99.txt as the input file. The numbers3.txt file consists of multiple whole numbers, two numbers per line separated by a space. Write a java program named ReadNumberFile2.java that reads the data from numbers3.txt and displays the data to the screen (two numbers per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that only whole numbers will be in the file). Test that your code works correctly by running the program using numbers3.txt, numbers4.txt, and numbers99.txt as the input file. iii) The numbers5.txt file consists of multiple whole numbers, three numbers per line separated by a space. Write a java program named ReadNumberFile3.java that reads the data from numbers5.txt and displays the data to the screen (three numbers per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that only whole numbers will be in the file). Test that your code works correctly by running the program using numbers5.txt, and numbers99.txt as the input file. iv) The numbers6.txt file consists of multiple whole numbers and floating-point numbers, three numbers per line (in the order whole number, floating point number, whole number) separated by a space. Write a java program named ReadNumberFile4.java that reads the data from numbers6.txt and displays the data to the screen (three numbers per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that the first and third number on every line is a whole number, and that the second number on every line is a floating-point number). Test that your code works correctly by running the program using numbers6.txt, and numbers99.txt as the input file. v) The numbers7.txt file consists of multiple whole numbers and strings, three values per line (in the order whole number, string, whole number) separated by a space. Write a java program named ReadNumberFile4.java that reads the data from numbers7.txt and displays the data to the screen (three values per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that the first and third number on every line is a whole number, and that the second value on every line is a string). Test that your code works correctly by running the program using numbers7.txt, and numbers99.txt as the input file. During the Week 7 practical complete the following exercises using the Eclipse IDE to produce working Java code. Coding Standards: When writing code in this unit you are required to adhere to the Coding Standards and General Principles as defined in the FAQ in vUWS. Your code for the following exercises should adopt these standards and general principles. 1) a) Create a week 7 Java project. Eight text files have been provided in the week 7 practical zip file. Copy the eight text files into the root folder of the project. In the exercises below you will write java code to read the data from these text files. The code will be very similar for each program. Do not use arrays or arraylists in any of these programs. There are several example files in the week 6 lecture which will assist with several aspects of this question. i) ii) The numbers.txt file consists of multiple whole numbers, one number per line. Write a java program named ReadNumberFile1.java that reads the data from numbers.txt and displays the data to the screen (one number per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that only whole numbers will be in the file). Test that your code works correctly by running the program using numbers1.txt, numbers2.txt, and numbers99.txt as the input file. The numbers3.txt file consists of multiple whole numbers, two numbers per line separated by a space. Write a java program named ReadNumberFile2.java that reads the data from numbers3.txt and displays the data to the screen (two numbers per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that only whole numbers will be in the file). Test that your code works correctly by running the program using numbers3.txt, numbers4.txt, and numbers99.txt as the input file. iii) The numbers5.txt file consists of multiple whole numbers, three numbers per line separated by a space. Write a java program named ReadNumberFile3.java that reads the data from numbers5.txt and displays the data to the screen (three numbers per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that only whole numbers will be in the file). Test that your code works correctly by running the program using numbers5.txt, and numbers99.txt as the input file. iv) The numbers6.txt file consists of multiple whole numbers and floating-point numbers, three numbers per line (in the order whole number, floating point number, whole number) separated by a space. Write a java program named ReadNumberFile4.java that reads the data from numbers6.txt and displays the data to the screen (three numbers per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that the first and third number on every line is a whole number, and that the second number on every line is a floating-point number). Test that your code works correctly by running the program using numbers6.txt, and numbers99.txt as the input file. v) The numbers7.txt file consists of multiple whole numbers and strings, three values per line (in the order whole number, string, whole number) separated by a space. Write a java program named ReadNumberFile4.java that reads the data from numbers7.txt and displays the data to the screen (three values per line of output). Ensure that your program works correctly for different length files (eg, longer files, shorter files, files with no data) and for files that don't exist. Your program will need to use appropriate try-catch statements (note: in this exercise you can assume that the first and third number on every line is a whole number, and that the second value on every line is a string). Test that your code works correctly by running the program using numbers7.txt, and numbers99.txt as the input file.
Expert Answer:
Answer rating: 100% (QA)
java import javaioFile import javaioFileNotFoundException import javaioFileWriter import javaioIOException import javautilScanner public class NumberArray private static final int ARRAYSIZE 100 privat... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
In this question assume that p and q are atomic formulae. (a) Compare and contrast path formulae and state formulae in temporal logic. [4 marks] (b) Describe and contrast the meanings of F(G p) and...
-
The following is a sufficient condition, the Laplace-Liapounoff condition, for the central limit theorem: If X 1 , X 2 , X 3 , . . . is a sequence of independent random variables, each having an...
-
Peninsula Supply Corporation provided the following schedule detailing the changes in the shareholders' equity accounts during 2016 and 2017. Determine the missing amounts. 2017 2016 Number of Number...
-
Suggest diversions that could make waiting less painful.
-
How does Einstein's explanation account for each of these characteristics of the photoelectric effect? a. The photoelectric current is zero for frequencies below some threshold. b. The photoelectric...
-
Hayley Hollis is admitted to the partnership of Rose & Novak. Prior to her admission, the partnership books show Greta Roses capital balance at $170,000 and Chris Novaks at $85,000. Requirements 1....
-
A company's manufacturing process has been experiencing quality issues, leading to an average of 12 defects per 500 units produced. Using Six Sigma methodologies, the company aims to improve and...
-
John works at a bakery in New York City. He is the only employee who makes chocolate cakes (and he only needs to make the cakes). On average, it takes him 30 minutes to make a cake. The average...
-
Given an initial state of an 8-puzzle problem and the final state to be reached. Show the path and the most cost-effective path and to reach the final state from the initial state using the A*...
-
The Allegheny Valley Power Company common stock has a beta of 0.80. If the current risk-free rate is 6.5% and the expected return on the stock market as a whole is 16%, determine the cost of equity...
-
Joanne is thinking about opening a long position in IBM. She plans to buy 133 shares and to ask for a broker loan of $6,407.18. The initial margin is 32.80% and the maintenance margin is 25.46%. The...
-
How much principal is repaid in the first payment interval on a $100,000 25-year mortgage? The mortgage is amortized over 25 years and the payments are monthly. The interest rate is 6% compounded...
-
Debt payments of $1,810.00 due today, $945 due in 113 days and $590.00 due in 325 days respectively are to be combined into a single payment to be made 160 days from now. Using an interest rate of...
-
Attached photo is a visualization of AgBr crystal structure using VESTA Illustrate and count its symmetry: 1. Identity 2. Rotation 3. Inversion n
-
The tractor is used to lift the 150-kg load B with the 24-mlong rope, boom, and pulley system. If the tractor travels to the right at a constant speed of 4 m/s, determine the tension in the rope when...
-
In 2012, Gale and Cathy Alexander hosted an exchange student, Axel Muller, for 9 months. Axel was part of International Student Exchange Programs (a qualified organization). Axel attended tenth grade...
-
Carl and Jenny adopt a Russian orphan. The adoption takes 2 years and two trips to Russia and is final in 2012. They pay $6,000 in 2011 and $7,500 in 2012 of qualified adoption expenses, and have AGI...
-
Professor Patricia (Patty) Pate is retired from the PalmSprings Culinary Arts Academy (PSCAA). She is a single taxpayer and is 68 years old. Patty lives at 98 Colander Street, Henderson, NV 89052....
-
Why may some people consider this to be incorrect? That is, why is the fact that the control account is kept in the General Ledger not enough to justify saying that the control account is part of the...
-
From the following figures, compile accounts receivable ledger and accounts payable ledger control accounts for the month, and ascertain what the net balances of the respective ledgers should be on...
-
The financial year of The Better Trading Company ended on 30 November 2014. You have been asked to prepare a Total Accounts Receivable Account and a Total Accounts Payable Account in order to produce...
Study smarter with the SolutionInn App