



|
|
P Dunn's Super CS1 Site
|
Programming Challenge Archive
Shapes World Programming Challenge
The Room
|
|
Java Application --
Room
// General Information
// ---------------------------------------------------
// File: Room.java
// Type: java application file
// Date: Sat Sep 30, 2000
// Name: Patrick Dunn
// Line: To find the distance from one corner of the
// room to the other.
// Application Description
// ---------------------------------------------------
/*
This will find the length from one corner to the other
corner of the room
*/
// Required Packages
// ---------------------------------------------------
import blue.io.*;
import blue.shapes.*;
// Application Class
// ---------------------------------------------------
class Room
{
static public void main (String args[])
{
// setup the dimensions of the room
double roomHeight = 8.0;
double roomLength = 14.0;
double roomWidth = 11.0;
// create the front rectangle
Rectangle frontRoom = new Rectangle(roomLength,roomHeig+
ht);
// create the top rectangle
Rectangle topRoom = new Rectangle(roomLength,roomWidth)+
;
// get the diagonals of the rectangle and add
double totalLength = frontRoom.diagonal() + topRoom.dia+
gonal();
// Display
IO.println("The distance between the corners is " + tot+
alLength + " feet");
}
}
// Demo
// ---------------------------------------------------
/*
$ java Room
The distance between the corners is 33.92900931136195 feet+
$
*/
|
|
|