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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 14:30, chaparro0512
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
image
Computers and Technology, 23.06.2019 07:00, lin550
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
image
Computers and Technology, 23.06.2019 18:00, MagicDragon4734
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
image
Computers and Technology, 24.06.2019 00:00, Kaylaonfleek0956
Consider the series where in this problem you must attempt to use the ratio test to decide whether the series converges. compute enter the numerical value of the limit l if it converges, inf if it diverges to infinity, minf if it diverges to negative infinity, or div if it diverges but not to infinity or negative infinity.
Answers: 1
You know the right answer?
Create a new java application called "weightedavgdataanalyzer" (without the quotation marks), that m...

Questions in other subjects:

Konu
Biology, 10.03.2021 03:20
Konu
Mathematics, 10.03.2021 03:20
Konu
Law, 10.03.2021 03:20