ECE 538 Assignment 3

Your submission should follow our general guidelines. Include a master index.html (in our standard format) that contains or links to all the problems. Use source-highlighting to display your code. Include source-code files and any required images.

  1. Modify your resistance program from the last assignment to accept a single string from the console (stdin) or from JOptionPane. Use the String.split function to parse an input string such as “R1 1000 R2 2000 R3 2000” into an array of Strings, and then create the corresponding resistor objects. You should consider generating an appropriate Resistor constructor. See Parsing Strings with split for examples.
  2. The Java Tutorial on try-with-resources has an example writeToFileZipFileContents. Put that example into a Java program and demonstrate it with some zip file.
  3. Use the Jama package to solve the matrix equation A x = b where A = [3 -1 0; 4 2 1; -3 2 4]; in MATLAB notaton and b = [1.8; 1.6; -1.3];
  4. Write a Java program to read a java file and generate an html file with < converted to &lt;, > converted to &gt; and & converted to &amp; Enclose the output in tags necessary to use the prettify javascript. See filecopy for file read/write examples.
  5. Write a class to represent a rational number. You may use the code in Rational.zip as a starting point. Incorporate and demonstrate the following capabilities:
    1. Write and test static functions like static public Rational add(Rational a, Rational b) and static public Rational multiply(Rationial a, Rational b)
    2. Create and test a member function invert() that swaps num and denom, thereby inverting the rational number. Which is better: (a) public void invert() which changes the current value or (b) public Rational invert() which returns a new Rational?
    3. demonstrate that you can calculate exact rational values for resistors in parallel. Use the example of 2, 3, and 4 ohms in parallel, and at least three other examples of your choosing.
  6. Continue your group work by devising some appropriate member functions (static and non-static) for your object class. Each member should demonstrate a unique set of tests to verify the behavior of your class.


Maintained by John Loomis, last updated 31 January 2020