CS1 Course Site

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

 
CS1 Course Site  
 
 
 
Wait , WAIT !!What's that word ? ( Class Notes ( without definitions ) )

Monday September 18 , 2000
 
For lab this week
  1. go
  2. If the ``Colatz lab'' is not finished,  finish it.
  3. If the ``web site' Developement Lab'' is not finished,  finish it.
  4. If the ``Programming assignment'' (GPS) is not finished,  finish it.
  5. Work on your web site,  + Shape your good work + your enthusiasm for the opportunity to develope a cool site with your instructor.
Some comments on the ``class notes'' section of the site...
  1. You are welcome to (and encouraged to) try to render the lectures in a fairly faithful manner.
  2. Alternatively,  you might simply write a paragraph or two summarizing the lecture for each class
\\ section {Class Notes} \\ subsection {Monday,  ------}
---------
---------
---------
\\ vs
---------
---------
---------
Remark
blue.shapes.   * is off limits for the current programming assignment.
Specification of the Rectangle Class
Constructor
new Rectangle (< double >,  < double >) --- > < rectangle >
Operators
< rectangle > .length () ----- > < double >
< rectangle > .width () ------ > < double >
< rectangle > .area () ------- > < double >
< rectangle > .perimeter () -- > < double >
< rectangle > .diagonal () --- > < double >
Commands
< rectangle > .display ()
Suppose we have a city block of length 480 and width 300 partitioned into 16 rectangular lots...
Tasks
  1. Model the block and a lot in terms of rectangles.
    double blockLength = 480;
    double blockWidth = 300;
    Rectangle block = new Rectangle (blockLength,  blockWidth);
    double lotLength = blockLength / 8;
    double lotWidth = blockWidth / 2;
    Rectangle lot = new Rectangle (lotLength,  lotWidth);

  2. Display the distance from one corner of the block to the far corner.
    IO.println (block.diagonal ());

  3. Declare a variable called pc and bind it to the percent of the block,  taken up by one lot.
    double pc = (lot.area () /block.area ()) * 100;
Problem
What is the surface area of a cylinder of height 28.5 and D of 11.6?
Note
The surface area of the cylinder equals:
  • the area of the top +
  • the area of the bottom +
  • the area of the side
Note
We are using problem decomposition
Note
We can explode the cylinder into circles and rectangles.
The Java program
< CLASS > ----- > SurfaceAreaApp
< NEEDS > ----- > import blue.shapes.   *;
< PROGRAM > --- >
/ /Establish the given information
double cylinerHeight = 28.5;
double cylinderDiameter = 11.6;
/ /Create the top
double topRadius = cylinderDiameter / 2;
Circle top = new Circle (topRadius);
/ /Create the bottom
double bottomRadius = cylinderDiameter / 2;
Circle bottom = new Circle (bottomRadius);
/ /Create the side
double sideHeight = cylinderHeight;
double sideLength = top.perimeter ();
Rectangle side = new Rectangle (cylinderHeight,  cylinderLength);
/ /Compute the surface area of the cylinder
double sa = top.area () + bottom.area () + side.area ();
/ /Display the result
IO.println ( ``The surface area =  ``+ sa + ``Square units.'');
A note on string Manipulation < string > + < string > --- > < string >
Ex
``Sun'' + ``shine'' =  ``sunshine''
< string > + < double > = < string > 

Ex
``x =  ``+ 5.2;
means ``x =  ``+ ``5.2''
means ``x = 5.2''