Homework assignment 1
Write a program in MATLAB that performs the following task:
Shows a text-based menu which looks exactly as shown in the figure below:
Unit conversion utility
Choose what conversion you want to perform:
Meters to miles
Miles to meters
Watts to horsepowers
Horsepowers to Watts
Kilograms to pound-mass
Pound-mass to kilogram
Insert a choice [1-6]:
Waits for the user to enter a number between 1 and 6 to choose one of the avalable options. If choice made by the user is not a number between 1 and 6 , the program must exit, suggesting to try again (by restarting the program) shown below:
Insert a choice [1-6]:
à¸
Invalid choice. Please, try again.
Then a ralid choice is made by the user, asks the user to insert a value to be converted according to the choice made. For example, if the user has chosen option 2 , the program should show:
Insert the quantity in mi to be converted into m :
After the user has inserted a ralue and pressed Enter, performs the conversion and show the results, formatted exactly as shown below:
Insert the quantity in mi to be converted into m :
12
12mi is equal to 19312.128m
Requirements
Use a custom function to format the message and read the input value to be converted from the user.
Use a custom function to format the output message providing the result of the unit conversion to the
Requirements matted exactly as shown below starting the program) shown below. Write a program in MATLAB that performs the following tasks: Homework assignment 1 Use a custom function to format the message and read the input value to be converted from the user. 12 mi is equal to 19312.128 m Insert the quantity in mi to be converted into m : After the user has inserted a value and pressed Enter, performs the conversion and show the results, for- Insert the quantity in mi to be converted into m When a valid choice is made by the user, asks the user to insert a value to be converted according to the Invalid choice.Please try again. Insert a choice [1-6]: 2. Waits for the user to enter a number between 1 and 6 to choose one of the available options. If choice Insert a choice [1-6]: 6.Pound-mass to kilogram 5.Kilograms to pound-mass 4.Horsepowers to Watts 3.Watts to horsepowers 2.Miles to meters 1.Meters to miles Choose what conversion you want to perform: Unit conversion utility 1.Shows a text-based menu which looks exactly as shown in the figure below