Monday, January 26, 2009

185 week 2

Overview of today's lab:
  1. examine code standards from Sun website
  2. use Skeleton programs on instructor's website
  3. write programs using Math library functions on integer and double variables

Details:
  1. These code standards from Sun haven't been updated in a long time, but then, they were good to begin with. Much of this document refers to things that we haven't done yet. Meanwhile, please take ten minutes or so for the parts that do make sense to us now. You should return to them several times over the semester.
  2. Check out updated Skeleton programs: SkelHello, SkelCL (CL for command-line inputs), and Skeleton, our general-purpose framework. If the meaning of something isn't clear to you, get friendlier with the person next to you. Note the components of the general-purpose Skeleton:
    • comment with author's name, date, and purpose of the program
    • an introduction that tells the user just what the program is about
    • civil prompts for user input
    • coherent labels for the output
    • whitespace for legibility all around
    • an opportunity for the user to try the program again with new inputs
    • notice of the program's ending
    The programs you submit will have all of these elements, and the program Skeleton here is designed to make it easy for you to concentrate on the interesting part of your work.
  3. Check the Sun Java API docs for the Math class. Notice the signatures for its methods. Many methods have more than one signature because they are suitable for more than one kind of input.
  4. Write and test programs in which you combine elements of Skeleton and the Math class to do the following:
    • program Circle.java: get a positive integer from the user and report the area of a circle whose radius is that integer
    • program Pythagoras.java: get a number from the user — let's suppose you call it x in your program — and compute and show the value of sin^2(x) + cos^2(x).
    • program Quadratic.java: get three values from the user and, supposing that they are the coefficients of a quadratic equation ax^2 + bx + c = 0, find the roots of the equation.
Show the instructor your work, and when you have finished all of it, zip your three programs into one file and send them in an e-mail. Soon we will have a more sophisticated manner of submitting.

No comments: