



|
|
Byron's CSC212 Web Site
|
Programming Challenge Archive
Shapes World
FarCorner
|
|
|
JavaApplication --
Far Corners
// General Information
// ---------------------------------------------------
// File: FarCornerApp.java
// Type: java application file
// Date: Wed Oct 4, 2000
// Name: Byron Bahr
// Line: Calculate the Distance between Room Corners
// Application Description
// ---------------------------------------------------
/*
This program calculates the distance from one
corner to the far corner of a room.
*/
// Required Packages
// ---------------------------------------------------
import blue.io.*;
import blue.math.*;
import blue.shapes.*;
// Application Class
// ---------------------------------------------------
class FarCornerApp
{
static public void main (String args[])
{
// Define the Given Information.
double roomLength = 14.0;
double roomWidth = 11.0;
double roomHeight = 8.0;
// Model the Floor of the Room.
Rectangle roomFloor = new Rectangle
(roomLength,roomWidth);
// Compute Diagonal of Floor.
double roomFloorDiag =
roomFloor.diagonal();
// Construct Helper Rectangle.
Rectangle roomHelper = new Rectangle
(roomFloorDiag,roomHeight);
// Compute the distance between corners.
double cornerDistance =
roomHelper.diagonal();
// Display the distance between corners.
IO.print ("The distance between corners is ");
IO.print (cornerDistance);
IO.println (" feet");
}
}
// Demo
// ---------------------------------------------------
/*
The distance between corners is 19.519221295943137+
feet
*/
|
|
|