Assignment-01c

 

 

 

Foreword

Resources

Code Listings

Foil Sets

Assignments

Solutions

External Resources

SiteMap

Search

Home

Up ] Assignment-01a ] Assignment-01b ] [ Assignment-01c ] Assignment-01d ] Assignment-02 ] Assignment-02a ] Assignment-03 ] Assignment-03a ] Assignment-03b ] Assignment-03c ] Assignment-03d ] Assignment-04 ] Assignment-04a ] Assignment-04b ] Assignment-05 ] Assignment-06 ] Assignment-07 ]

Writing a Java application

There are two types of Java programs: applications and applets. An applet is a web-based Java program embedded in an HTML document. An application, on the other hand, is not web-based. It is developed and run at the command line, much like a C program.

Your first Java programming assignment is to write a small application. Before starting this assignment, you should should become familiar with the Java programming environment on osprey7.

You may also use Java compilers on other systems if your prefer, or a programming environment such as J++ or Cafe'. For these initial programming assignments, a JDK1.0 compiler is o.k.; later you must use JDK1.1, which is what we have on osprey7.

Write a Java application that reads in a set of floating point numbers, using Java type double, (the set should be variable in size, up to some maximum size) and computes the mean and standard deviation of these numbers.

You may wish to refer to the programs called Average.java, which computes the mean of a set of integers, and Volume.java in the NPAC Java Resources page. These programs demonstrate the use of a package called Console.java to read integers and doubles from standard input. These programs (Average.java, Volume.java and Console.java) can be copied from the web page or from my directory ~njm/public_html/Java/lang. For each program, there is also a file with a .run extensions, such as Average.run, which shows the output of the program.

For convenience sake, here is a text version of the equation for standard deviation. Assume that there are N numbers from x1 to xN and that the mean is written xbar.

 stdev = sqrt( 1/N * (Sum from i=1 to N ((xbar - xi) ** 2)))  

Also note that there are methods Math.sqrt and Math.pow (exponent).

The code should be neatly written, easy to read, and well documented.
Submit your assignment by linking the description of your program, a link to the Java source code and a small file showing sample output (like my .run files) to your homework page.