% -----------------------------------------------------
% menulengthunitconversion.m
% -----------------------------------------------------
% Write a program that asks the user to input a length in meters,
% creates a menu with options to convert given length to feet or 
% yards and uses a switch case statement to complete the 
% unit conversion. 
% -----------------------------------------------------
% Notes: None. 
% -----------------------------------------------------
% Copyright and license details available at matlabmarina.com
%------------------------------------------------------

clear;
clc;

% read in length in meters
meters = input('Enter length in meters : ');

% menu command for conversion
choice = menu('Convert from meters to other units','feet','yards');

% define the convertion ratios
ftRatio = 3.28084;
yrdRatio = 1.09361;

bdChoice = 'Quit';

% convert to specified units
switch choice
    case 1
        result = meters * ftRatio;
        unitChoice = 'feet';
    case 2
        result = meters * yrdRatio;
        unitChoice = 'yards';
    otherwise
        result='Quit';
end

% display result based off choice
% if strcmp(unitChoice, bdChoice)

if choice==0
    fprintf('exited menu');
else
    fprintf('%0.f m = %.5f %s\n',meters,result,unitChoice);
end