Question: function out = convertUnits ( inputValue , conversionType ) % Insert the conversion logic here % This switch statement should handle different types of conversions

function out = convertUnits(inputValue, conversionType)
% Insert the conversion logic here
% This switch statement should handle different types of conversions
switch conversionType
case 1%fahr2cels
out =(inputValue -32)*5/9;
case 2%cels2fahr
out =(inputValue *(9/5))+32;
case 3%cm2in
out =(inputValue /2.54);
case 4
out =(inputValue *2.54);
case 5%met2ft
out =(inputValue *3.2808);
case 6
out =(inputValue /3.2808);
case 7%km2mi
out =(inputValue /1.6093);
case 8
out =(inputVlaue *1.6093);
case 9%gr2oz
out =(inputValue /28.3495);
case 10
out =(inputValue *28.3495);
case 11%kg2lb
out =(inputValue *2.2046);
case 12
out =(inputValue /2.2046);
case 13%t2lt
out =(inputValue /1.061);
case 14
out =(inputValue *1.061);
% Add more cases as necessary for each type of conversion
end
%%
disp('Welcome to the Unit Conversion Program');
while true
inputValue = input('Please enter the number to be converted (or type ''exit'' to quit): ','s');
% Check if the user wants to exit
if strcmpi(inputValue, 'exit')
break;
end
% Convert the input value to a number
inputValue = str2double(inputValue);
% Check if the input is valid
if isnan(inputValue)
disp('Invalid number. Please try again.');
continue;
end
% Display conversion options
disp('Choose the conversion type:');
disp('1. fahrenheit to celsius');
disp('2. celsius to fahrenheit');
disp('3. centimetre to inches');
disp('4. inches to centimetre');
disp('5. meters to feet');
disp('6. feet to meters');
disp('7. kilometres to miles ');
disp('8. miles to kilometres');
disp('9. grams to ounces');
disp('10. ounces to grams');
disp('11. kilogram to pounds');
disp('12. pounds to kilogram');
disp('13. tonne to ton');
disp('14. ton to tonne');
conversionType = input('Enter the number of your choice: ');
% Validate the chosen conversion type
if conversionType <1|| conversionType >14% Adjust according to the number of options
disp('Invalid option. Please try again.');
continue;
end
% Call the conversion function
convertedValue = convertUnits(inputValue, conversionType);
% Output the result
fprintf('Converted value: %.2f
', convertedValue);
end
disp('Thank you for using the Unit Conversion Program!');
why am i getting not enough arguments error?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!