Question 11 (18 points) Write a complete Java program (no documentation required) that will read all...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 11 (18 points) Write a complete Java program (no documentation required) that will read all the data from a file, create a histogram from the data, and then display it on the screen. The data file (called ages.txt) is error-free and contains only ages of a large sample of random students in a school. All the ages are between 18 and 30, inclusive. The size of the file is unknown, but each row of the data file has the age of just one student. You must use several methods to accomplish this task, including: 1. [6 marks] a Java method that takes a data file (notice the parameter type), extracts all the data from it and produces a frequency array. Use the following header for your method: public static int[] getFrequencyData (Scanner theData) A frequency array is a single array that compactly records that there were 4 students of age 18, 8 students of age 19, 13 students of age 20, etc. 2. [6 marks] a Java method that when given a frequency array, displays a histogram like the example following on the screen that shows the frequency of each age. Use the following header for method: public static void displayFrequencies(int[] frequencies) your In the diagram, each dash after the age number represents a student of that age. For example, according to the following diagram, there are 4 students of age 18 and 3 students of age 22. There is nobody of age 27, 29 nor 30. 18 19 20 21 22 --- 23 24 26 3456 25 -- 27 28- 29 30 Total: 55 students 3. [6 marks] Other methods and statements necessary to complete the rest of the program requirements, including properly calling the above two methods. Note: Put all the methods, including main method in a class so that your program can compile and run. Question 11 (18 points) Write a complete Java program (no documentation required) that will read all the data from a file, create a histogram from the data, and then display it on the screen. The data file (called ages.txt) is error-free and contains only ages of a large sample of random students in a school. All the ages are between 18 and 30, inclusive. The size of the file is unknown, but each row of the data file has the age of just one student. You must use several methods to accomplish this task, including: 1. [6 marks] a Java method that takes a data file (notice the parameter type), extracts all the data from it and produces a frequency array. Use the following header for your method: public static int[] getFrequencyData (Scanner theData) A frequency array is a single array that compactly records that there were 4 students of age 18, 8 students of age 19, 13 students of age 20, etc. 2. [6 marks] a Java method that when given a frequency array, displays a histogram like the example following on the screen that shows the frequency of each age. Use the following header for method: public static void displayFrequencies(int[] frequencies) your In the diagram, each dash after the age number represents a student of that age. For example, according to the following diagram, there are 4 students of age 18 and 3 students of age 22. There is nobody of age 27, 29 nor 30. 18 19 20 21 22 --- 23 24 26 3456 25 -- 27 28- 29 30 Total: 55 students 3. [6 marks] Other methods and statements necessary to complete the rest of the program requirements, including properly calling the above two methods. Note: Put all the methods, including main method in a class so that your program can compile and run.
Expert Answer:
Answer rating: 100% (QA)
Heres the complete Java program import javaioFile import javaioFileNotFoundException import javautil... View the full answer
Related Book For
Integrated Accounting
ISBN: 978-1285462721
8th edition
Authors: Dale A. Klooster, Warren Allen, Glenn Owen
Posted Date:
Students also viewed these programming questions
-
Create a generic class called MyArrayList that includes the following instance methods: 1. add(index, value) 2. indexOf(value) 3. remove(index) 4. set(index, value) 5. toString() 6. addAll(list) 7....
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Explain how the structure of the balance sheet corresponds to the accounting equation.
-
A new accountant at La Maison Ltée is trying to identify which of the following amounts should be reported as cash and cash equivalents in the April 30 year-end statement of financial...
-
Indicate whether each of the following statements is true or false by writing T or F in the answer column. 1. Some types of contracts must be in writing to be enforceable. 1. __________ 2. The parol...
-
How does make determine whether a target needs to be rebuilt?
-
Lansbury Inc. had the balance sheet shown on the next page at December 31, 2011. During 2012, the following occurred.1. Lansbury Inc. sold part of its investment portfolio for $15,000. This...
-
Why would you perform a silent installation? What is the purpose of a password complexity policy? Oracle offers a free download of all editions of the Oracle Database. How does the company derive...
-
Pace Company purchased 20,000 of the 25,000 shares of Saddler Corporation for $525,000. On January 3, 2011, the acquisition date, Saddler Corporations capital stock and retained earnings account...
-
(a) A 250 V (phase), 10 kVA, 3-phase, 50 Hz, 1000 rev/min, star-connected synchronous machine has a synchronous reactance of 500. Stator resistance and rotational losses are both negligible. A field...
-
Explain the difference between a cash dividend, a stock dividend, a special dividend, and a stock buyback.
-
What is the catering theory of dividends and how would it influence a manager looking to improve the value of her firm through dividend policy? What does the empirical evidence say about the catering...
-
Explain the role of agency conflicts between managers, shareholders, and bondholders in corporate payout policy.
-
Managerial Motives for Takeovers Outline the managerial motives for takeovers.
-
Explain the importance of taxes in dividend policy. What are the real world factors that would encourage firms to follow a high dividend policy?
-
1.Jabba-Dabba-Doo Inc. renovated its warehouses exactly two years ago at a cost of $3.5 million. The renovations were considered leasehold improvements, so the cost was subject to straight-line...
-
The purpose of this case is to come up with a contingency plan[s] in order to sustain the program Move With Me, a program that serves thousands of community members throughout Lower Manhattan. The...
-
Directions: For each of the definitions, write the letter of the appropriate term in the space provided. a. Corporation b. Retained Earnings Statement c. Stock dividend d. Sole proprietorship e....
-
In this problem, you will process transactions involving fixed assets for Savoy Merchandise Co. for the month of November 2013. In addition, you will complete the monthly accounting cycle. The...
-
How is the quantity entered in the Sales Invoice window for a sales return transaction?
-
A child receives \($100\),000 as a gift, which is deposited in a bank account earning 6 percent compounded semiannually. If \($5\),000 is withdrawn at the end of each half year, how long will the...
-
The plan was to leave $5,000 on deposit in a savings account for 15 years at 6.5 percent interest compounded annually. It became necessary to withdraw $1,500 at the end of the fifth year. How much...
-
A deposit of $3,000 is made in a savings account that pays 7.5 percent interest compounded annually. How much money will be available to the depositor at the end of 16 years? a. $8,877 b. $10,258 c....
Study smarter with the SolutionInn App