1 /* 2 finding the yellow area of an image. 3 */ 4 5 package shapes; 6 7 import shapes.SSquare; 8 import shapes.SCircle; 9 import shapes.SRectangle; 10 import java.lang.Math; 11 12 public class YellowSpace { 13 public static void main(String[] args){ 14 double edge = 400; 15 double d1 = 60; 16 double d2 = 30; 17 double d3 = 15; 18 SSquare largegray = new SSquare(edge); 19 double largegrayA = largegray.area(); 20 System.out.println("largegray area = " + largegrayA); 21 //finding the large yellow square 22 SCircle largecircle = new SCircle((edge-(2*d1))/2); 23 SSquare largeyellow = largecircle.inscribingSquare(); 24 double largeyellowA = largeyellow.area(); 25 System.out.println("largeyellow area = " + largeyellowA); 26 //finding the small gray square 27 SCircle middlecircle = new SCircle((((Math.sqrt(largeyellowA))/2) - d2)); 28 SSquare smallgray = middlecircle.inscribingSquare(); 29 double smallgrayA = smallgray.area(); 30 System.out.println("smallgray area = " + smallgrayA); 31 // finding the small yellow square 32 SCircle smallcircle = new SCircle((((Math.sqrt(smallgrayA))/2)-d3)); 33 SSquare smallyellow = smallcircle.inscribingSquare(); 34 double smallyellowA = smallyellow.area(); 35 System.out.println("smallyellow area = " + smallyellowA); 36 //finding the yellow space 37 double yellowspace = ((largeyellowA-smallgrayA)+smallyellowA); 38 System.out.println("yellow space area = " + yellowspace); 39 } 40 }