![henryzx900](/avatars/17065.jpg)
henryzx900
28.05.2021 •
Computers and Technology
Java program with comments in main and in each method.
A city is divided into 100 neighborhoods, each with a unique name. Every three months, each neighborhood reports the prices of four houses sold; not all neighborhoods have sales to report every three months. A file contains the sales data in the format:
neighborhood price price price price
For example, Midtown 23055 10000 19000 32009 (Note: prices are in whole dollars)
Design a Java class with a main method that does the following:
Invokes method readData which reads the data from the input file, stores values into arrays and returns the number of records read in.
Invokes method modifyData, passing an array of double as the parameter. The method modifies the value in the array based on rules specified below.
Invokes method sortArrays to parallel sort the arrays of double and String. The method should be invoked only once.
Prints to a file the neighborhood name and average of the three neighborhoods that have the highest average prices, in descending order (highest average price first), and the three neighborhoods that have the lowest average prices in ascending order (lowest average price first). The neighborhood should be left adjusted, the price right adjusted with two decimal places and the header row should be included. The output should be in the form:
Neighborhood Avg Price
Eastside 108162.50
Greenfields 67576.06
Southside 60967.78
Neighborhood Avg Price
Chelsea 47663.28
Westside 48830.93
Uptown 57200.00
Method Details:
1. readData:
2. Receives an array of String and array of double
3. Reads the neighborhood name as String and the four prices as integer from a file (name of your choice)
4. Stores the neighborhood name in the array of String and the average of the 4 prices in the array of double.
5. Returns the number of neighborhood records read in as an integer
6. modifyData:
7. Receives an array of double as the parameter and an integer representing the number of records read in by readData
8. Computes the overall average home price for all homes read in by readData (the average of the averages)
9. For the number of records read in from the input file, increases the average price for each neighborhood by 10% if the average home price for that neighborhood is below the overall average home price homes sold and decreases the average price for each neighborhood by 15% if the average home price for that neighborhood is above the overall average.
10. sortArrays:
11. Receives the arrays of double and String and an integer representing the number of records read in by readData as parameters
12. Parallel sorts the arrays, only for the number of records read in by readData, with the primary sort on the array of double in descending order.
Solved
Show answers
More tips
- F Family and Home Ways to Attract Wealth into Your Home...
- F Family and Home 5 Tips for Choosing Toys for Your Child...
- L Leisure and Entertainment How to Find a Phone Number by Address: The Ultimate Guide...
- P Philosophy How to Properly Create a Vision Board?...
- C Computers and Internet What is Web 2.0 and How Does it Work?...
- S Style and Beauty Is Photoepilation the Solution to Unwanted Hair Forever?...
- O Other What is a Disk Emulsifier and How Does it Work?...
- F Family and Home What does a newborn need?...
- F Family and Home Choosing the Right Car Seat for Your Child: Tips and Recommendations...
- F Food and Cooking How to Get Reconfirmation of Registration?...
Answers on questions: Computers and Technology
- C Computers and Technology Ninety percent of the fastest-growing jobs require some kind of postsecondary education. True False...
- C Computers and Technology Which of the following is a series of organized activities working towards a particular goal...
- B Biology Ocean currents - surface ocean currents can occur on local and global scales and are typically wind-driven, resulting in both horizontal and vertical water movement....
- C Chemistry How many grams of a 31.6% potassium sulfate solution would contain 617 g potassium sulfate?...
- M Mathematics 1tara s jewelry box contains two gold bracelets and two silver braceltara randomly choose two bracelets. what is the probability that bare silver bracelets?...
- G Geography Name the four parts of the mantle from top to bottom....
- H History The war between nepal and britain is also known as . war....
- S Spanish Select the word from the list that best fits the definition sirve comida y bebidas....
- M Mathematics In a factory, 50 out of 1,000 pens are found to be defective. what percentage of the pens is defective?...
- P Physics What is a chicken’s rate of acceleration that speeds up from 4 mph (mi/h) to a top speed of 9 mi/h in 0.5 hr? 2.5 mi/h/s -2.5 mi/h/s 2.5 mi/h2 10 mi/h2...
Ответ:
Your answer would be D because he has to present his findings on sales revenues to his management team, meaning that he will have multiple things to present Hope this helps :)