1 /* 2 A program to compute the area of the yellow space in an image. 3 */ 4 package shapes; 5 6 public class YellowSpace { 7 8 public static void main(String[] args) { 9 10 //Given measurements 11 double BigGrayLength = 400; 12 double LargeYellowCornerToLargeGrayEdge = 60; 13 double SmallGrayCornerToLargeYellowEdge = 30; 14 double SmallYellowCornerToSmallGrayEdge = 15; 15 16 //Area of the big yellow diamond 17 double BigYellowRadius = ((BigGrayLength - (LargeYellowCornerToLargeGrayEdge*2))/2); 18 SCircle BigYellowCircle = new SCircle (BigYellowRadius); 19 SSquare BigYellowSquare = BigYellowCircle.inscribingSquare(); 20 double BigYellowArea = BigYellowSquare.area(); 21 22 //Area of the small gray square 23 SCircle BigYellowInscribing = BigYellowSquare.inscribingCircle(); 24 double BigYellowInscribingRadius = BigYellowInscribing.radius(); 25 double SmallGrayCircumscribingRadius = (BigYellowInscribingRadius-SmallGrayCornerToLargeYellowEdge); 26 SCircle SmallGrayCircumscribing = new SCircle (SmallGrayCircumscribingRadius); 27 SSquare SmallGraySquare = SmallGrayCircumscribing.inscribingSquare(); 28 double SmallGrayArea = SmallGraySquare.area(); 29 30 //Area of the small yellow diamond 31 SCircle SmallGrayInscribing = SmallGraySquare.inscribingCircle(); 32 double SmallGrayInscribingRadius = SmallGrayInscribing.radius(); 33 double SmallYellowCircumscribingRadius = (SmallGrayInscribingRadius - SmallYellowCornerToSmallGrayEdge); 34 SCircle SmallYellowCircumscribing = new SCircle (SmallYellowCircumscribingRadius); 35 SSquare SmallYellowSquare = SmallYellowCircumscribing.inscribingSquare(); 36 double SmallYellowArea = SmallYellowSquare.area(); 37 38 //Calculate and display total yellow area 39 double YellowArea = (BigYellowArea - SmallGrayArea + SmallYellowArea); 40 System.out.println("Area of yellow region --> " + YellowArea + " millimeters squared"); 41 42 } 43 44 45 } 46