% This script will call a function to calculate the area and circumference
% of a circle. User will supply the radius.

clear all
clc


disp('We will find the area and circumference of any circle!');
r = input('What is the radius of your circle? ');

% call our function that returns area and circumference
[a,c] = circleData(r);

fprintf('\nThe area of your circle is %.2f square units.\n\n',a);
fprintf('The circumference of your circle is %.2f units.\n\n',c);

function [a,c] = circleData(r)
% return the area and circumference for a circle of any radius
% usage: [a,c] = circleData(r) where r is the radius of the circle. note:
% vectors are allowed

% call functions to perform calculations
a = areaCalc(r);
c = circumCalc(r);

% nested function to handle the area calculation
function y = areaCalc(s)
y = pi*s.^2;
end

% nested function to handle the circumference calculation
function z = circumCalc(t)
z = 2*pi*t;
end

end