% This is the sample program of unit1 redone % in MATLAB % A sample program file: 8ex2.m % FALL 2001 % ___________________________________ % Jacob Y. Kazakia jyk0 % September 4, 2001 % Recitation Instructor: J.Y.Kazakia % Recitation Section 01 % ___________________________________ % Purpose: This program calculates the area of a sector % of circle, given the radius of the circle in % meters and the angle of the sectorin degrees. % Algorithm: The area of the entire circle is given by % the formula: % Area = pi * radius * radius (here pi = 3.1415927 ) % If the sector angle is theta degrees, then its area is: % Sector_area = ( theta / 360 ) * pi * radius * radius % PROMPT FOR AND READ THE INPUT radius = input(' \n\nEnter the radius of the circle in meters >>>'); theta = input(' \n\nEnter the angle of sector in degrees >>>'); % ECHO PRINT THE ENTERED VALUES fprintf(' \n\n We will now calculate the area of a sector of a circle \n' ); fprintf(' The radius of the circle ( meters) was given as : %5.2f \n' , radius ); fprintf(' The angle of the sector ( degrees) was given as: %5.1f \n ' , theta ); % calculation ( do you really need a computer for this? ) area = (theta/360 )* pi * radius * radius; fprintf(' The area ( square meters)is calculated as : %5.2f ' , area );