CS1 Course Site

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

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

Wednesday September 27 , 2000
 
< polygon > .circumscribingCircle () -- > < circle >
< polygon > .inscribingCircle () ------ > < circle >
< circle > .circumscribingPolygon () -- > < polygon >
< circle > .inscribingPolygon () ------ > < polygon > 

Ex
What is the area of the ``ring'' bounded by the inscribing circle and the circumscribing circle of a heptagon of side 25.2?
Polygon p = new Polygon (7,  25.2);
Circle circumscribingCircle = p.circumscribingCircle ();
Circle ic = p.inscribingCircle ();
double ringArea = circumscribingCircle.area () - ic.area ();
IO.println ( ``The ring area is:   ``+ ringArea); 

Some notes on Strings
The type ``string'' has the name
String
String animal1;
animal1 =  ``zibra'';
String animal2;
animal2 =  ``fish'';
String wierdAnimal = animal1 + animal2;
IO.println (wierdAnimal);
String s = IO.readString ();
Problem
A line of n congruent squares collectively has area a.   What is the perimeter of the line of squares?
Ex
double a = 72.9;
double oneSquareArea = a / 3;
double oneSquareSide = Math.sqrt (oneSquareArea);
double p = oneSquareSide * 8;
IO.print ( ``The perimeter is:   ``);
IO.print (p);
IO.println ();
The Basic Application Architecture
< CLASS > --- > LineOfSquaresBAA
< PROGRAM > - >

/ /Declare variables
int nrSquares;
double figureArea;
double squareArea;
double squareSideLength;
int eeCount;
double perimeter;
/ /Read the data area
nrSquares = IO.read_int ();
figureArea = IO.read_double ();
/ /Compute the area of a square
squareArea = figureArea /nrSquares;
/ /Compute the side length of a square
squareSideLength = Math.sqrt (squareArea);
/ /Compute the number of external edges eeCount = (2 * nrSquares) + 2;
/ /Compute the perimeter
perimeter = eeCount * SquareSide;  / /Display the result IO.println ( ``perimeter =  ``+ perimeter);