ENGR1121 – Computing Applications in Mechanical Engineering
Lab Conditional Structures
Lab due: end of lab
Total points: 20
Labs are to be individual work. You may use MATLAB Marina, MATLAB’s help, and your notes. Lab work will be
graded during lab time and working results must be shown to the lab instructor by the end of the scheduled
lab time. All MATLAB programs and functions must be completed and submitted in accordance with the
Computing Assignment Format and the MATLAB Coding Style. Submit an electronic copy of your lab work to
the appropriate Dropbox Folder in GSU’s Folio by the end of lab. No hard copy needed unless specifically
requested by the instructor.
Grading
Each problem will be graded according to: program design (identifying inputs/givens, process, and outputs;
algorithm) and program style (program comments, variable names, proper formatted input and output
including units) 25%, and program correctness 75%.
Lab Work
1. (5 points) Write a script that calculates the variable mode (a string) which represents the mode of
transport used to travel a certain distance according to the following definition. You are given a variable
called distance that represents the distance to be covered in miles.
distance <= 2 miles: ‘Walk’
2 miles < distance <=10 miles: ‘Bicycle’
10 miles 30 miles: ‘Delta Airlines’
2. (5 points) Write a MATLAB program that will display a menu with the donut choices: glazed, cake, jelly, and
crème; and display the cost of the donut selected from the menu. The donut costs are: glazed $0.50, cake
$0.50, jelly $0.65, and crème $0.80. The menu can be generated using the MATLAB statement
choice=menu('Donut Choices','glazed','cake','jelly','creme'); The menu function will return an integer
corresponding to the number of the button selected. The variable choice will be assigned the value
corresponding to the menu button pressed.
3. (10 points) Given an item’s cost in dollars and an indicator of whether the item is taxable or not, compute
and display the total cost of the item to the purchaser. The indicator for whether an item is taxable or not
should be a character: T for taxable and E for exempt. Assume the tax on the item if it is taxable is 6.5%.
The item cost and taxable indicator should be read in from the user. The optional argument 's' used
with the input function as shown in Figure 1 will allow characters and strings to be read in. To compare a
variable holding a character to a character literal, enclose the character literal in single quotes, for example
(var == 'A').
% read in a character using input function
indicator = input('Enter taxable or exempt (T or E): ','s');
Figure 1, Input Function Set up to Read in Characters or Strings
1
Instructor: Dr. Priya Goeser
Lab Conditional Structures
of 1
Report
Tell us what’s wrong with it:
Thanks, got it!
We will moderate it soon!
Struggling with your assignment and deadlines?
Let EduBirdie's experts assist you 24/7! Simply submit a form and tell us what you need help with.
Free up your schedule!
Our EduBirdie Experts Are Here for You 24/7! Just fill out a form and let us know how we can assist you.
Take 5 seconds to unlock
Enter your email below and get instant access to your document