1 /* 2 Assignment 3, problem 1 (The Messy Desk): this program computes the available area 3 of the open space on the desk covered with objects. Makes use of NPW functionality 4 */ 5 6 package shapes; 7 8 9 public class WorkArea { 10 11 public static void main(String[] args) { 12 //Given measurements of objects (in inches) 13 int deskHeight = 24; 14 int deskWidth = 36; 15 double bookWidth = 8.5; 16 int bookHeight = 11; 17 int dinnerPlateRadius = 8; 18 double cupRadius = 1.35; 19 20 //"Objects to think with" 21 SRectangle desk = new SRectangle(deskHeight, deskWidth); 22 SRectangle book = new SRectangle(bookHeight, bookWidth); 23 SCircle plate = new SCircle(dinnerPlateRadius); 24 SCircle cup = new SCircle(cupRadius); 25 SSquare coaster = cup.inscribingSquare(); 26 27 //Calculating the area of the desk 28 double deskArea = (desk.area()); 29 System.out.println("Desk area = " + deskArea); 30 31 //Calculating the area of the objects on the desk 32 double booksArea = (book.area() * 2); //Two books 33 double dinnerPlatesArea = (plate.area() * 3); //Three dinner plates 34 double coastersArea = (coaster.area() * 3); //Three coasters 35 double objectsTotalArea = (booksArea + dinnerPlatesArea + coastersArea); 36 System.out.println("collective area of objects = " + objectsTotalArea); 37 38 //Desk area available for work to be done 39 double openDeskArea = (deskArea - objectsTotalArea); 40 System.out.println("Area of open work space = " + openDeskArea); 41 } 42 }