TASK: Write a script that compares the area of three circles to a square.
COMMENTS: The square has a "radius" of 1, so an area of 4 square units. The area of a circle of radius r is pi*r^2. We have three circles, of radius 1.05, 1.10, and 1.15 units. We want to know which circle's area is closest to the area of the square.
INSTRUCTIONS:
Let "s" be the area of the square; set it to 4. s = ?; Use the names "a1", "a2" and "a3" for the areas of the circles of radius 1.05, 1.10, and 1.15, and compute their areas. Make sure these areas are printed out. a1 = ? a2 = ? a3 = ? Use the names "e1", "e2" and "e3" for the errors, that is, the absolute value of the difference between the area of the square and the area of circles 1, 2 and 3. Make sure these errors are printed out. e1 = abs ( ? - ? ) e2 = ? e3 = ? Depending on which of e1, e2, and e3 is the smallest, print the appropriate message, such as if ( ? AND ? ) fprintf ( 'Circle 1 is the closest in area.\n' ); elseif ( ? AND ? ) ? else ? end
SUBMIT: Your work should be stored in a script file called "hw002.m". Your script file should begin with at least three comment lines:
% hw002.m % YOUR NAME % This script (describe what it does) % Add any comments here that you care to make.If this problem is part of an assignment, then submit it to Canvas.