Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Assignment

Create a program called CalcWeightedAvgWithExceptions2 by modifying Horstmann's program DataAnalyzer.java (Section 7.5, pp. 350-351, and also in this module), according to the specifications below. 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.

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. You need not, but you may, also allow the user to reenter an output file name if exceptions in opening the output file are caught.

1. Modify the structure of the main method in Horstmann's DataAnalyzer.java so that, in addition to prompting the user to enter 'data.txt' as the name of the input file, you call a method to calculate the weighted average prompt the user for the name of an output file, and then call a method to print the results to the output file.

2. Your methods should handle exceptions in trying to read the input file in a way similar to the way Horstmann handles them in DataAnalyzer.java. Your method for calculating the weighted average need not handle any exceptions (though it may), and how your method for printing the results handles exceptions is up to you.

3. The main focus is to give your program the ability to re-enter the input file name if the specified exceptions are caught.

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

Java, Programming

  • Category:- Java
  • Reference No.:- M92405496
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Java

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As