Write a matllab program that will do as converter from meters to feet, pounds to
ID: 3559944 • Letter: W
Question
Write a matllab program that will do as converter from meters to feet, pounds to kg, celsius to fahrenheit
Write three different functions every function in one file as follows
1- MTF (Meter to feet) this function named MTF will receive an input in meter and return the value in feet
2- PTK (Pound to Kilogram) this function named PTK will receive an input in pound and return the value in kg
3- CTF (Celsius to Fahrenheit) this function named CTF will receive an input in Celsius and return the value in Fahrenheit
Then create a script file that will call these functions when required as in the following example
1 meters to feet
2 pounds to kg
3 Celsius to Fahrenheit
4 Exist
Explanation / Answer
1) meters to feet
function [] = convert(length)
l=length*3.28084;
fprintf('%0.2f meters = %0.2f feet ',length,l)
2) pounds to kg
function [] = convert2(weight)
w=weight*0.453592;
fprintf('%0.2f pounds = %0.2f kg ',weight,w)
3) Celsius to Fahrenheit
function [] = convert2(temp)
t=temp*33.8;
fprintf('%0.2f Celsius = %0.2f Fahrenhite ',temp,t)
----------------------------------------------------
code to call these function
length=input('Enter length in meter: ');
convert(length)
weight=input('Enter weight in pounds: ');
convert2(weight)
temp=input('Enter temperature in Celsius');
convert3(temp)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.