Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LABORATORY ASSIGNMENT 7: CREATING SELECTION STRUCTURES: IF-ELSEIF-ELSE VERSUS SWITCH STATEMENT Objective In this lab you will use selection structures to create programs that assign a

image text in transcribedimage text in transcribed

LABORATORY ASSIGNMENT 7: CREATING SELECTION STRUCTURES: IF-ELSEIF-ELSE VERSUS SWITCH STATEMENT Objective In this lab you will use selection structures to create programs that assign a letter grade to test grade scores. You will create two programs that assign the correct letter grade to a respective score every for every possible input value. For the first program you will define a function that uses an if-elseif-else structure and for the second one you will use a switch statement. To test the correctness of the defined functions you will call each function from the command window repeatedly by entering different scalar values as input (scores), observe the output and modifjy the programs as needed. By the end of the laboratory practice you will be able to correctly define an if-elseif-else and a switch structure and to distinguish the advantages and disadvantages of each structure type New MATLAB Function:s error('message string')- generates a MATLAB error and displays a customized error message Procedure Create a total of two MATLAB function files that performs the following tasks 1. Define a function that prints the correct letter grade based the single input gradeScore. Use an if-elseif-else statement to return the correct letter grade for a given test score. The grades should be based on the following criteria (Note that for this case defining an output in the function is not needed) Table 1. Letter Grades for Corresponding Test Score Ranges Score 9 to 10 8 to 9 7 to 8 6 to 7 0 to 6 Grade 2. Provide help comment(s) to indicate the purpose of this function and to specify that the input must be a scalar value 3. Be specific when defining relational operators. The score 9.0 should be assigned with the letter A, and the score 8.9 should be assigned with a letter B, and so forth. 4. Include a statement that prints "Invalid Input" for negative scores or values greater than 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 3 Lnai 6323

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

3642159389, 978-3642159381

More Books

Students also viewed these Databases questions