/* * A program that calculate the remaining space of a messy desk */ package shapes; public class WorkArea { public static void main(String[] args){ // Declaring basic measurements and bind them to variables. double DeskDepth, DeskWidth, BookLength, BookWidth, CupRadius, PlateRadius; DeskDepth = 24.0; DeskWidth = 36.0; BookLength = 11.0; BookWidth = 8.5; CupRadius = 1.35; PlateRadius = 8.0; // Unnecessary variables that could have been replaced by just a number. double NumOfCoasters, NumOfPlates, NumOfBooks; NumOfCoasters = 3.0; NumOfPlates = 3.0; NumOfBooks = 2.0; // Create objects to think with and bind them with values from other variables. SRectangle Desk = new SRectangle(DeskDepth, DeskWidth); SCircle Glass = new SCircle(CupRadius); SSquare Coaster = Glass.circumscribingSquare(); SCircle Plate = new SCircle(PlateRadius); SRectangle Book = new SRectangle(BookLength, BookWidth); double CoastersArea = NumOfCoasters * Coaster.area(); double PlatesArea = NumOfPlates * Plate.area(); double BookArea = NumOfBooks * Book.area(); // Calculating the remaining space double CollectiveArea = (CoastersArea + PlatesArea + BookArea); double RemainingArea = (Desk.area() - CollectiveArea); // Display the result. System.out.println("The area that may still be used for studying: " + RemainingArea + " square inches"); } }