Make a new java application called weightedavgwithexceptions

Assignment Help JAVA Programming
Reference no: EM131593873

Assignment

Make a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the following guidelines and using try-catch-finally blocks in your methods that read from a file and write to a file, as in the examples in the lesson notes for reading and writing text files.

Input File

The input file - which you need to make and prompt the user for the name of - should be called 'data.txt', and it should be created according to the instructions below.

The input file should contain (in order): the weight (greater than 0 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.

For example, you might have these values in your input file (data.txt):
0.5 3 10 70 90 80 20

Creating the Input file

To create the input file, while in NetBeans with your project open, click to highlight the top-level folder of your project in the projects tab at the upper left. Then starting with the NetBeans File menu, do

File->New File

Keep the Project name at the top; keep Filter blank

For Categories choose Other (at the bottom of the categories list)

For File Types choose 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 one in 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. Then save this data.txt input file.

It's important that your input file is where NetBeans will look to find it. The above instructions should make sure that that happens.

Main Method

Your main method should contain just three lines like these:

ArrayList<Double> inputValues = getData();

double weightedAvg = calcWeightedAvg(inputValues);
printResults(inputValues, weightedAvg);

where the printResults method should prompt the user for the name of the output file and print to that output file.

Output

Given the sample values above in the data.txt input file, the output file should contain something 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.

Prompting for names of input file and output file

Make sure you prompt the user for the name of the input file (even though we know what it is). You can use a prompt like: "Enter "data.txt" (no quotes) for the name of the input file: "

Also prompt the user for the name of the output file. If you use code like that in Horstmann's Total.java program to create the output file, the output file should be located at the same place as the input file. Check the NetBeans Files tab (next to the Project tab in the upper left) to see both the input and output files.

Reference no: EM131593873

Questions Cloud

Party insulated from risk : Moral hazard is the prospect that a party insulated from risk may behave differently from the way it would behave if it were fully exposed to the risk.
Find the equation of the plane : Find the equation of the plane with normal 2i - 3j + k that contains the point (1, 0, 1).
What is the best estimate of the current stock price : Its required return (rs) is 12%. What is the best estimate of the current stock price?
Difference between descriptive and inferential statistics : What is the difference between descriptive and inferential statistics. Provide an example of each? What assumptions apply to each
Make a new java application called weightedavgwithexceptions : Make a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the given guidelines.
Find the cartesian form of given equation : Given that a plane passes through the point (2, 3, -5), and the vector 2i + k is normal to the plane, find the cartesian form of its equation.
Currency futures contracts relative to forward contracts : Disadvantage of currency futures contracts relative to forward contracts including? which of the following concerning futures contracts is true?
Define how are psychopaths different than sociopaths : What are the characteristics. How are psychopaths different than sociopaths
Management expects this lack of growth to continue : Knight Supply Corp. has not grown for the past several years, and management expects this lack of growth to continue.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd