APlusGrades

Not Rated (0)

$15/per page/Negotiable

About APlusGrades

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing,Foreign Languages,Geography,Geology,Health & Medical,HR Management,Law,Management,Physics,Programming,Science,Statistics Hide all
Teaching Since: Jul 2017
Last Sign in: 365 Weeks Ago
Questions Answered: 1850
Tutorials Posted: 1850

Education

  • Graduate in Biology and Nutrition, MBA Finance
    Florida State University
    Aug-2000 - Jul-2007

Experience

  • Ass. Relationship Manager
    Penn-Florida
    Mar-2009 - Feb-2016

Category > Computer Science Posted 21 Jul 2017 My Price 12.00

Any guidance would be greatly appreciated.

Good afternoon, 

I've been really struggling with this assignment. Any guidance would be greatly appreciated.

 

Assignment

Create, using NetBeans, a complete Java program called CalcWeightedAvgDropLowest according to the following guidelines.

For this program, instead of getting the data from the user via System.in, get only input and output file names from the user. (See Horstmann, pp. 319, 320).

The input file - which you need to create and prompt the user for - should be called 'data.txt',and it should be created according to the highlighted instructions below. The input file should contain (in order): the weight, the number, n, of lowest numbers to drop, and the numbers to be averaged after dropping the lowest n values. See the example below.  Also, include a method called printResults that prompts the user for the name of an output file and then prints the results to that user-designated output file.

Your main program should contain just three lines like these:

ArrayList<Double> inputValues = getData();

double weightedAvg = calcWeightedAvg(inputValues);

printResults(inputValues, weightedAvg);

The inputValues come from a single line in your "data.txt" file such as the following:

0.5 3 10 70 90 80 20

The output file should contain something 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.”

Creating the Input file

To create the input file, while in NetBeans with your project open, click to highlight the name of the project in the Projects tab at the upper left part of the IDE. That tab should be called CalcWeightedAvgDropLowest. Then:

File-→New File…

Keep the Project name at the top; keep Filter blank

 Categories → Other (at the bottom of the categories list)

             File Types → Empty File (at the bottom of the files list)

Next>

FileName: data.txt

Folder:  this should be blank; if it's not, delete whatever's there

Finish

In the empty file data.txt that you just created, add a single line of data like the example above, where the weight is a double (greater than 0.0 and less than or equal to 1.0) and the other numbers are the number, n, of lowest values to drop and then the numbers to be averaged after dropping the lowest n values. Also, instead of displaying the output to the console, let the user choose a file name (as in Horstmann's example), and write the output to a file with that user-supplied name (e.g., output.txt).

Thoughts

  • It's important that your input file is where NetBeans will look to find it. The above instructions should make sure that that happens.
  • Make sure you prompt the user for the name of the input file. You can use a prompt like: "Enter "data.txt" (no quotes) for the name of the input file: "
  • Note that if you run this program from the command line, the input file should be in the same directory as your .class file.

Answers

Not Rated (0)
Status NEW Posted 21 Jul 2017 10:07 AM My Price 12.00

Hel-----------lo -----------Sir-----------/Ma-----------dam----------- ----------- -----------Tha-----------nk -----------you----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m -----------on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I

Not Rated(0)