- examine code standards from Sun website
- use Skeleton programs on instructor's website
- write programs using Math library functions on integer and double variables
Details:
- 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.
- 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
- comment with author's name, date, and purpose of the program
- 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.
- 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.
- program Circle.java: get a positive integer from the user and report the area of a circle whose radius is that integer
No comments:
Post a Comment