COMP 14-090 Summer I 2000

Assignment 6: An Array Calculator

Assigned: Thursday, June 15
Due: Tuesday, June 20
Worth: 80 points

Description

This assignment will use the skills of reading from a text file, taking command-line arguments, and manipulating an array of doubles. The text file to read from will be given as a command-line argument.  Open the text file and read in the first number, which will be an integer.  This number will tell you how many doubles are in the file.  Read in each double into a single array.  Print out the name of the file you read, the contents of the array, and the results of the following operations:

Use DecimalFormat to round the results to one decimal place. You only need one class for this program, but each operation listed above should be in a separate method.  Don't print anything to the user inside these methods -- only print to the user inside main (or inside another method that only does output).

Hints


What to Turn In

Steps to Follow
  1. Follow the instructions in Getting Started with Visual J++ under "Creating a New Project."  Use Assignment6 as your project name.
  2. Follow the instructions under "Adding a New Class."  Name your class ArrayCalc.
  3. Write in English the algorithm that you would use to complete this assignment.
  4. Take each part one at a time and convert that to Java.
  5. To run the program with a command line argument, select Assignment6 Properties... from the Project menu.  The window that pops up is below.  Pick Custom then type the command line arguments (put complete filename in quotation marks) after ArrayCalc in the Arguments box.  Make sure that the Program box says JView.exe and not WJView.exe
Notes

The following output window is just an example. You don't have to use the same formatting. To get black text on a
white background, I pasted the captured image into the Paint program and inverted the colors.

The input file for the following example contained:

7
99.8
67.8
88.4
76.2
101.4
89.6
94.3


Michele Clark
clark@cs.unc.edu

Back to COMP 14