



|
|
CS1 Course Site
|
Programming Challenge Archive
Shapes World
Far Corner
|
|
|
JavaApplication --
FarCorner
// General Information
// ---------------------------------------------------
// File: FarCornerApp.java
// Type: java application file
// Date: Fri Sep 29, 2000
// Name: Kara Becker
// Line: Compute the distance from one corner of a room t+
o the far corner of a room.
// Application Description
// ---------------------------------------------------
/*
Compute the distance from one corner of a room to the fa+
r corner of a room using the given information.
*/
// Required Packages
// ---------------------------------------------------
import blue.io.*;
import blue.shapes.*;
// Application Class
// ---------------------------------------------------
class FarCornerApp
{
static public void main (String args[])
{
//Record the given information.
double lengthRoom = 14.0;
double widthRoom = 8.0;
double heightRoom = 11.0;
//Create the room.
Rectangle base = new Rectangle(lengthRoom,widthRoom);
Rectangle wall = new Rectangle(base.diagonal(),heightRoom+
);
double wallDiag = wall.diagonal();
//Display the results.
IO.println("The distance between the corners is " + wallD+
iag + " feet.");
}
}
// Demo
// ---------------------------------------------------
/*
$ javac FarCornerApp.java
$ java FarCornerApp
The distance between the corners is 19.519221295943133 f+
eet.
$
*/
|
|
|