subject

Create a new java application called "weightedavgdataanalyzer" (without the quotation marks), that modifies the dataanalyzer. java in horstmann section 7.5, pp. 350-351 according to the specifications below.
the input file should be called 'data. txt' and should be created according to the highlighted instructions below. note that even though you know the name of the input file, you should not hard-code this name into your program. instead, prompt the user for the name of the input file.
the input file should contain (in order): the weight (a number greater than zero and less than or equal to 1), the number, n, of lowest numbers to drop, and the numbers to be averaged after dropping the lowest n values.
you should also prompt the user for the name of the output file, and then print your results to an output file with the name that the user specified.
your program should allow the user to re-enter the input file name if one or more of the exceptions in the catch clauses are caught.
your methods for getting data and printing results should each throw a filenotfoundexception which should be caught in the main method.
use try-with-resources statements (links to an external site.)links to an external site. in your methods for getting and printing the data, and so avoid the need to explicitly close certain resources.
in your readdata method, use hasnextdouble to check ahead of time whether there's a double in the data. that way when you try to get the nextdouble, your code won't throw a nosuchelementexception.
you can use a writefile method that does all the work (i. e., does not call a writedata method the way that horstmann’s readfile method calls a readdata method). use a try-with-resources statement in your writefile method when creating a new printwriter.
the inputvalues come from a single line in a text file (data. txt) such as the following:
0.5 3 10 70 90 80 20
the output in the output file must give the weighted average, the data and weight that were used to calculate the weighted average, and the number of values dropped before the weighted average was calculated.
your output should look very much like the following: "the weighted average of the numbers is 42.5, when using the data 10.0, 70.0, 90.0, 80.0, 20.0, where 0.5 is the weight used, and the average is computed after dropping the lowest 3 values."
write the output to a file with the filename that the user chose to name the output file (e. g., output. txt). don't hard-code the output file name in your program.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
You should try to photograph people on bright sunny days because the light will be best a) true b) false
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Drag the tiles to the correct boxes to complete the pairs. match the errors with their definitions. #name #value #ref when a formula produces output that is too lengthy to fit in the spreadsheet cell arrowright when you enter an invalid cell reference in a formula arrowright when you type text in cells that accept numeric data arrowright when you type in a cell reference that doesn’t exist arrowright reset next
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Suppose a cpu with a write-through, write-allocate cache achieves a cpi of 2. what are the read and write bandwidths (measured by bytes per cycle) between ram and the cache? (assume each miss generates a request for one block.)
Answers: 1
question
Computers and Technology, 24.06.2019 06:50
What are the things you are considering before uploading photos on social media?
Answers: 1
You know the right answer?
Create a new java application called "weightedavgdataanalyzer" (without the quotation marks), that m...
Questions
question
Mathematics, 09.02.2021 06:20
question
Mathematics, 09.02.2021 06:20
question
Health, 09.02.2021 06:20
question
Mathematics, 09.02.2021 06:20
Questions on the website: 13722360