head 1.5; access; symbols IT1FALL00:1.2; locks; strict; comment @# @; 1.5 date 2001.01.29.12.38.02; author dbc; state Exp; branches; next 1.4; 1.4 date 2001.01.27.21.14.55; author dbc; state Exp; branches; next 1.3; 1.3 date 2001.01.17.02.07.51; author dbc; state Exp; branches; next 1.2; 1.2 date 2000.09.08.20.08.59; author dbc; state Exp; branches; next 1.1; 1.1 date 2000.08.30.19.34.07; author dbc; state Exp; branches; next ; desc @@ 1.5 log @Modified Files: hw1.html hw2.html @ text @ Applications of Information Technology I: Homework 1

CIS 5930-04
Spring 2001

Assignment #1

Writing a Java application with class structure

Your first programming assignment is to write a Java application that uses classes and exceptions. The aim is to give you some practice with Java syntax and make sure that you understand the class concept.

Before starting this assignment, you should ensure you can access your account on the CSIT host computer, sirah. I recommend you also familiarize yourself with the editors and Java development environment on this computer. You may, if you prefer, develop the current homework using Java compilers on other systems, possibly using a programming environment such as J++ or Cafe (if you use any of these programming environments, do not use them to generate Java code for you automatically). But you will need the sirah account to submit your homework. Also note that for later homeworks, some use of the editors and/or the JDK system on sirah and associated hosts will almost certainly be required.

The Assignment

Design and implement a class, Matrix to represent matrices. You will probably need three instance variables in the class:
   int nrows ;    // The number of rows
   int ncols ;    // The number of columns
   float [][];    // Array holding the elements of the matrix
Write a constructor that takes two arguments--the number of rows and columns--and allocates an array to hold the elements.

You should also write (at least) the following public methods.

The add and multiply methods must throw exceptions if the shapes of the matrices do not allow the matrices to be combined according to the rules of matrix arithmetic (see below).

The methods add and multiply may be implemented either as instance methods or as static methods on the Matrix class: you should decide which you think is most suitable and explain your reasons.

You must also write a test program for this class: design an application that prompts the user to type in the shape and element values for two matrices. Create instances of the Matrix class for each one. Combine the two matrices using both add and multiply, and use the toString method to print out a description of both results.

Show a couple of runs of the program (for small matrices, e.g. number of rows and columns may be two or three). Be sure to demonstrate a case of successfully combining matrices, and also one which fails because the add or multiply method gives an exception. Make sure your program works for "non-square" matrices--i.e. number of rows not equal to number of columns.

Definitions for matrix arithmetic:


c = a + b

    c.getNumRows() == a.getNumRows()
    c.getNumCols() == a.getNumCols()

    c.get(i, j) == a.get(i, j) + b.get(i, j)
with constraints:
    a.getNumRows() == b.getNumRows()
    a.getNumCols() == b.getNumCols()

c = a * b

    c.getNumRows() == a.getNumRows()
    c.getNumCols() == b.getNumCols()

    c.get(i, j) == Sum over k of terms: a.get(i, k) * b.get(k, j)
with constraint:
    a.getNumCols() == b.getNumRows()

To simplify things, you may assume that indices i, j, etc, are defined to run from 0 to n - 1, rather than the normal mathematical convention (which is 1 to n). Here n is the number of rows or colums, as appropriate.

Submission of your Homework

Your submission should consist of files including
  1. A description of your program, preferably in Microsoft Word, HTML, or plain text format,
  2. all Java source code, and
  3. file or files showing sample output from one or more runs. This may be captured by cutting and pasting from a command-line window.
On sirah you will find a directory called /home/project/ it1spring01/homework1/uid where uid is your login ID. To submit Assignment I, please copy your files into this directory.

Grading

For this assignment, there will be a total of 20 points. Your submission will be assessed on:


Useful resources:
Please send questions to Bryan Carpenter at dbc@@csit.fsu.edu.

@ 1.4 log @Modified Files: hw1.html Removed Files: formulas.gif @ text @d147 1 d149 1 @ 1.3 log @Modified Files: hw1.html io.html Added Files: BufferedReaderTest.java.txt hosts.html Removed Files: BufferedReaderTest.java guidelines.html jdk.html @ text @d14 1 a14 1

Writing a Java application with class structure

d31 1 a31 1 But you will need the sirah account to submit your d33 1 a33 1 and/or the JDK system on sirah and associated hosts will d38 1 a38 1 Design and implement a class, Matrix to represent matrices. d50 1 a50 1
  • A set method with three arguments i, j, d53 1 a53 1
  • A get method with two arguments i, j, d55 1 a55 1
  • inquiry methods getNumRows and getNumCols which d57 1 a57 1
  • An add method which adds together two matrices and returns d60 1 a60 1
  • A multiply method which multiplies together the d64 1 a64 1
  • A toString method which returns a formatted String d67 1 a67 1 "\n", to separate rows). d69 1 a69 1 The add and multiply methods must throw d71 25 a95 1 to be combined according to the rules of matrix arithmetic. a125 1 a130 23

    The methods add and multiply may be implemented either as instance methods or as static methods on the Matrix class: you should decide which you think is most suitable and explain your reasons.

    You must also write a test program for this class: design an application that prompts the user to type in the shape and element values for two matrices. Create instances of the Matrix class for each one. Combine the two matrices using both add and multiply, and use the toString method to print out a description of both results.

    Show a couple of runs of the program (for small matrices, e.g. number of rows and columns may be two or three). Be sure to demonstrate a case of successfully combining matrices, and also one which fails because the add or multiply method gives an exception. Make sure your program works for "non-square" matrices--i.e. number of rows not equal to number of columns. d142 4 a146 7

    d171 2 a172 2 Using javadoc comments is not required, but it is encouraged, and may gain extra credit (javadoc-generated HTML can be @ 1.2 log @*** empty log message *** @ text @d3 1 a3 1 Applications of Information Technology: Homework 1 d8 1 a8 1

    CIS 6930-01
    Fall 2000

    d14 1 a14 1

    Using Web Technology

    d16 135 a150 8 Your success in CSIT courses has led to a new job as the Minister for Information Technology in your favorite country. This is a new position and you have decided to establish your personal popularity and enthusiasm for the office by starting a new project aimed at using the the latest information technology to solve a major need for your country. Please surf the web and start to learn about uses of Java, JavaScript, XML, CORBA, Wireless devices and write a report on any such project explaining how the technologies will be used d152 2 a153 1 Examples: d156 9 a164 1 Use of Java to link to databases for healthcare applications d166 5 a170 1 Use of Enterprise Javabeans to build an online lottery d172 10 a181 2 Use of XML to build a single country wide data format for all government offices (so the population need not wait in line so much) d183 1 a183 2 Use of Java to build a system to control wireless devices used by rescue workers in an eartquake a184 3

    List any URL's you find particularly useful and give a synopsis of what you learnt from the 6 best sites you found d186 10 a195 2 d198 1 a198 2 Please send questions to Geoffrey Fox at fox@@csit.fsu.edu or Bryan Carpenter at dbc@@csit.fsu.edu. a202 3 @ 1.1 log @Added first homework @ text @d14 1 a14 1

    Using the Web

    @