Java help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • normbrc
    New Member
    • Nov 2007
    • 2

    Java help

    I need to create a program in Java that:

    1. Asks the user to enter the name of the input file containing heart rate measurements, and input the file name. .txt format

    2. Ask the user to enter the name of the output file where the output HTML document will be saved, and input the file name

    3. Open the input file by using a BufferedReader object

    4. Open the output file by using a PrintWriter object

    5. Output to the file the appropriate opening HTML tags

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

    For each series of heart rates in the input file, do the following:

    Input the series of numbers from the input file and store them in an array

    Compute the minimum, maximum, and fitness quotient for the series
    Output one row of the HTML table to the output file, with the fitness quotient, minimum and maximum heart rarates, and the list of heart rates

    Output to the file the appropriate closing HTML tags

    Close the input and output

    dont need a solution, just help
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    It is quite suited to be a complete batch process, i.e. you pass the names of the
    input file and output file on the command line and off it goes: it processes the
    input, while producing the output and then quits. If anything goes wrong somewhere
    during the process, simply print a diagnostic message and exit.

    Don't stick all your code in the main() method but create small and simple separate
    methods that do one thing; they should do it well. A first 'frame' for your process
    could be this:

    [code=java]
    public class Processor {
    //
    private void testArgs(String[] args) { ... }
    //
    private BufferedReader getInput(String name) { ... }
    //
    private PrintWriter getOutput(Strin g name) { ... }
    //
    public static void main(String[] args) {
    testArgs(args); // bails out if not two arguments given

    // get input and output; process input producing output
    // bail out if something goes wrong
    process(getInpu t(args[0]), getOutput(args[1]));
    }
    }[/code]

    kind regards,

    Jos

    Comment

    Working...