% Example 2.3 carbon dating

% solution
% 1. prompt user
% 2. read in value
%3. convert percentage to fraction
% 4. calculate age using  t = 1/lambda * log (q/q0)
% 5. output result

percent = 0;        % percentage of c14 remaining
ratio = 0;          % q/q0
age = 0;            % age = - (1/lambeda) * log(q/q0)
lambda = 0.00012097;    % lambda constant for c14 decay

percent = input('enter percentage (%) of c14 remaining: ');

% disp('echo:');
% disp(percent);

ratio = percent / 100;

% disp('echo:');
% disp(ratio);

age =  -(1/lambda) * log (ratio);

disp('age (years):');
disp(age);
