Write the output to a file with that user-supplied name

Assignment Help JAVA Programming
Reference no: EM131596775

Assignment

Create a program called CalcWeightedAvgWithExceptions, and use try-catch-finally blocks in your methods, as in the examples try-catch-finally examples from the class notes for this lesson, which are also shown in the file 'TryCatchFinally.txt' available in this module.

The input file should be called 'data.txt' and 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, your program should include methods for getting the input from the data.txt file, calculating the weighted average according to the data in the data.txt file, and printing the results to a user-designated output file.

Your main method 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 like 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 top-level folder of your project, which should be called CalcWeightedAvgWithExceptions. 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).

Reference no: EM131596775

Questions Cloud

What is dollar amount of amortization for june : On December 31, 2016, Happy Corporation issued $560,000, 14%, What is dollar amount of amortization for June 30, 2017
Provide the accounting entries to record the sale : Provide the accounting entries to record the sale, and the subsequent return of the assets, assuming that the returns occur in accordance with expectations
Evidence-based practice project : Provide an initial reference list of a minimum of five resources your CLC group has consulted during the selection process.
Discuss the electronic medical record technology : Develop a 5- to 7-slide presentation that addresses the requirements for a project governance board investigating the feasibility.
Write the output to a file with that user-supplied name : Create a program called CalcWeightedAvgWithExceptions, and use try-catch-finally blocks - write the output to a file with that user-supplied name
What is the amount of the first year''s interest payment : On January 1, Bank, Rupp & Baroque, Inc. issued $50,000 worth of 10minus -year, 9% bonds for $48,890. What is the amount of the first year's interest payment
Discuss environmental management as a competitive advantage : Discussion: Sustainable Development and the Environment. In a blog post to key stakeholders, discuss using environmental management as a competitive advantage.
Create a binary search tree class : CS501 - Advanced Structured Programming and Algorithms Homework - Create a binary search tree class and You MUST use the pseudocodes given in the class
How much cash dividend was paid to preferred shareholders : Out of Africa, a multi-national corporation had a very successful year. How much of the cash dividend was paid to the PREFERRED shareholders

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