Write a java program to practice the use of java file i/o.

Assignment Help JAVA Programming
Reference no: EM13948379

Write a Java program to practice the use of Java file I/O. Class methods are needed to break up solution in smaller parts.
Program will read several series of heart rates from a file, compute min, max, & fitness quotient for each series, and output the input data and computed info in an HTML document.

The following 3 files are attached:

1.sample-input.txt, which is a small sample input file,

2.sample-output.html, which is a small sample output file corresponding to the sample-input.txt input file,

3.many-heart-rates.txt, which is a big sample input file.

Problem:

You have been hired by a medical research group, led by a famous cardiologist that has developed something they call the fitness quotient. The idea is to have a person walk on a treadmill for several minutes and to take his/her heart rate measurement a couple times a minute. This leads to a series of heart rates, e.g., <60,66,72,75,72,74>. The person's fitness quotient is twice the smallest heart rate in this series, divided by the sum of the smallest and largest heart rates. (Notice that neither the duration of the test nor the frequency of heart rate measurements is important, and in general these may vary from test to test and from individual to individual without affecting the fitness quotient.) For example, the individual whose heart rates are those in the above example would have a fitness quotient of 0.889 = (2*60)/(60+75).
The medical research group is interested in a program that will read a file containing heart rate measurements for several anonymous individuals, and will create from it an HTML file that looks like this when viewed in a browser:

Fitness Quotient Minimum Heart Rate Maximum Heart Rate Heart Rate Series
0.919 68 80 68, 69, 76, 78, 77, 77, 78, 80
0.887 67 84 67, 69, 78, 83, 83, 84, 79, 82, 79, 84, 83, 82, 83, 84, 79, 83, 80, 78, 84, 84
0.894 63 78 63, 71, 73, 78, 76

The program will be invoked with two command line arguments, the input file name and the output file name.

The program will perform the following actions:

1.Open an input file whose name is the first argument to the program (args[0]), by using a BufferedReader object

2.Open an output file whose name is the second argument to the program (args[1]), by using a PrintWriter object

3.Output to the file the appropriate opening HTML tags

4.Output to the file the header row of the table

5.For each series of heart rates in the input file, do the following: 1.Input the series of numbers from the input file and store them in an array 2.Compute the min, max, & fitness quotient for the series 3.Output one row of the HTML table to the output file, with the fitness quotient, min & max heart rates, and the list of heart rates 6.Output to the file the appropriate closing HTML tags 7.Close the input and output files.

Make sure to handle all possible IOException exceptions generated by the file I/O calls.
The input file will contain heart rate measurements for several anonymous individuals in the following format:
<number of heart rate series>
<number of heart rate measurements for first individual>
<heart rate 1>
<heart rate 2>
<heart rate 3>
...
<number of heart rate measurements for second individual>
<heart rate 1>
<heart rate 2>
<heart rate 3>
...
...
where the first line <number of heart rate series> is the number of heart rate series in the input file; after that, <number of heart rate measurements for first individual> is the length of the first heart rate series, which is followed by the corresponding number of heart rate measurements, one per line of the input file. Each following heart rate series follows the same format. See sample-input.txt and many-heart-rates.txt for sample input files in this format. Note that the solution has to work with an input file following this format but with an arbitrary number of heart rate series.

The output file format will be HTML. The general structure of the program's output will be the following:
<html>
<body>
...
</body>
</html>
The body of the HTML output file will contain a table.


Attachment:- sample-input.zip

Reference no: EM13948379

Questions Cloud

Calculate the unit cost and the cost of finished goods : Calculate the unit cost and the cost of finished goods inventory under absorption costing. Calculate the unit cost and the cost of finished goods inventory under variable costing.
Absorption mechanisms in nonmetallic materials : 1. Briefly explain what determines the characteristic color of (a) a metal and (b) a trans- parent nonmetal. 2. Briefly explain why some transparent materials appear colored while others are color- less. 3. Briefly describe the three absorption mecha..
What is your greatest challenge as an organization : Please tell me about your organization. What is your greatest challenge as an organization? What do you think is your organization's greatest opportunity? Who are your current customers? How do you currently market to those customers
What is the rational for methodology : What are the four purposes of this chapter: (1) describe the research methodology of this study, (2) explain the sample selection, (3) describe the procedure used in designing the instrument and collecting the data, and (4) provide an explanation ..
Write a java program to practice the use of java file i/o. : Write a Java program to practice the use of Java file I/O. Class methods are needed to break up solution in smaller parts.Program will read several series of heart rates from a file, compute min, max, & fitness quotient for each series, and output ..
Calculate the unit cost and the cost of ending inventory : Calculate the unit cost and the cost of ending inventory under variable costing. What is the contribution margin per unit?
Reflectivity of light at normal incidence : It is desired that the reflectivity of light at normal incidence to the surface of a trans- parent medium be less than 5.0%. Which of the following materials in Table 21.1 are likely candidates: soda-lime glass, Pyrex glass, periclase, spinel, pol..
Complete a job requirements job analysis : Complete a job requirements job analysis on a position with which you are familiar. Focus on the specifics tasks of the associated KSAOs that lead to success in meeting the tasks.  (showing detail both in the tasks and the KSAOs type, proficiency, et..
Create table command, and modify it to create a new table : Start with this CREATE TABLE command, and modify it to create a new range_partitioned table named CH07EMPLOYEE_RANGE that contains the same column as the employee table.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Design a java class to represent a 3-d geomtetric shape

Design and implement a Java class to represent a 3-D geomtetric shape of your choice. The class should contain a constructor, appropriate data fields and methods to return the volume of the shape, and the surface area of the shape and any other me..

  Write a java program that (1) defines a base/super class a

Write a Java program that (1) Defines a base/super class A, a subclass B (inherits from A), and a subclass C (inherits from B). The A class must have a method f() which is not implemented in A,

  The array at the index method

have an array, how do i remove an entry from the array at the index method?

  If there are 4 command line arguments

If there are 4 command line arguments (a b c filename.dat) then the engine should take a,b,c and store the resulting x1 and x2 in filename.dat working in silent mode (no use of screen)

  Design the class line type to store a line

Design the class lineType to store aline. To store a line, you need to store the values of a (coefficient of x), b(coefficient of y), and c. Your class must contain the following operations.

  Write a java program

Create a "JApplet" that contains two parallel arrays with at least five friends' names and phone numbers. Allow the user to enter either a name or phone number and to click a "JButton" to display the other.

  100 chairs arranged in a circle

At some point in time, the person in chair #1 will be told to leave the room. The person in chair #2 will be skipped, and the person in chair #3 will be told to leave. Next to go is person in chair #6. In other words, 1 person will be skipped initial..

  How are java source code files named

What is the purpose of the wait(), notify(), and notifyAll() methods? How are Java source code files named?

  Approximate the volume of cheese in a rectangular hunk

You will create a program that will approximate the volume of cheese in a rectangular hunk of Swiss cheese. For this approximation you will assume that the holes in the Swiss cheese are of two types: spherical bubbles (all of the same size) or cyl..

  Object oriented programming-getting started with classes

Suppose you are car shopping and want to store information about possible choices. Model, and implement an automobile class. Use a UML drawing tool such as Umbrello or Microsoft Visio to create a class diagram. Your class should have at least cons..

  Write an object-oriented java program to manipulate data

I want a simple java solution matching all the specifications in the document. The java program has to be made using Eclipseversion 4.2.1.

  Create a sales tracking program named salestracking.java

create a sales tracking program named SalesTracking.java. This program must track monthly sales as well as compute average yearly sales, total sales for the year, and which month had the highest sales and which month had the lowest sales.

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