Question

MATLAB Code:

?MATLAB Code:

Write a function that converts a given letter grade it will print its equivalence in numerical scale. For example if the user enters A, then your function should print a message stating that the grade must be between 90 and 100. B is between 80 and 89, etc. Everything under 60 is F. Use the switch-case function. Use fprintf to display the results on the screen.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB function that converts a given letter grade into its equivalence numerical scale:

function grade2numeric ()
Grade = input('Enter grade A/B/C/D/F: ','s');
switch Grade
case 'A'
fprintf('The grade must be between 90 and 100 \n')
case 'B'
fprintf('The grade must be between 80 and 89 \n')
case 'C'
fprintf('The grade must be between 70 and 79 \n')
case 'D'
fprintf('The grade must be between 60 and 69 \n')
case 'F'
fprintf('The grade must be under 60 \n')
otherwise
fprintf('Invalid grade \n')
end

end

Save the function as 'grade2numeric.m' in the current MATLAB folder. Run the function by typing the function name in the command window.

>> grade2numeric
Enter grade A/B/C/D/F: B
The grade must be between 80 and 89
>> grade2numeric
Enter grade A/B/C/D/F: F
The grade must be under 60
>> grade2numeric
Enter grade A/B/C/D/F: h
Invalid grade

Add a comment
Know the answer?
Add Answer to:
MATLAB Code: ?MATLAB Code: Write a function that converts a given letter grade it will print...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that will provide a user with a grade range if they enter...

    Write a C++ program that will provide a user with a grade range if they enter a letter grade. Your program should contain one function. Your function will accept one argument of type char and will not return anything (the return type will be void), but rather print statements to the console. Your main function will contain code to prompt the user to enter a letter grade. It will pass the letter grade entered by the user to your function....

  • 1. Create a program that takes a numerical score and outputs a letter grade. 2. In...

    1. Create a program that takes a numerical score and outputs a letter grade. 2. In this program, create two void functions titled makeScore and theGrade with an int argument. 3. The function makeScore should have a Reference parameter and theGrade should have a Value parameter. Note: Specific numerical scores and letter grades are listed below: 90-100 = Grade A 80-89 = Grade B 70-79 = Grade C 60-69 = Grade D 0-59 = Grade F 4. The function makeScore...

  • Matlab a) Write a MATLAB code that takes the grade letters from the user and provide him/her with the GPA for that seme...

    Matlab a) Write a MATLAB code that takes the grade letters from the user and provide him/her with the GPA for that semester Enter your grades (letters): AABBC (input) Your GPA is 3.2 output) b) Write a Matlab user defined function to that takes a letter grade and return a numeric grade as shown in the table below. Any other value should give an error message (Invalid Grade). You function name should be Letter2Grade Use the following information to calculate...

  • Please write in MATLAB code: 1. Write a function called myMin4 that will take in four...

    Please write in MATLAB code: 1. Write a function called myMin4 that will take in four numbers and returns the minimum value. You may NOT use the built-in min() function. Run the function for the following: myMin4(4, 8, 12, 15) myMin4(18, 9, 1, 6) myMin4(8, -2, 2, 10) 2.   Write a function called classAverage that takes in an array of numbers and returns the letter grade of the class average. The grade ranges are as follow: Average >90 = A...

  • This program should be written in C Thoroughly following the Code Conventions, write an efficient program,...

    This program should be written in C Thoroughly following the Code Conventions, write an efficient program, which ask the user for their numeric grade, and determines and displays the equivalent letter grade, based on the following information: Use appropriate data types and initialize the variables correctly Use the following grading scale: A: 90 - 100 B: 80 - < 90 C: 70 - < 80 D: 60 - < 70 F: 0 - < 60 If the input is invalid,...

  • Write a function called testneg with one input and no outputs. The function will test to...

    Write a function called testneg with one input and no outputs. The function will test to see if the input value is negative. If it is negative, use fprintf to print the message to the screen Warning: The input value n is negative. where n is not literally the letter n, but is the value of the input to the function. Assume the input value is a floating-point number, so use an appropriate format in the fprintf to print the...

  • Please use Matlab to solve and show your full codes Write a script file Ask the...

    Please use Matlab to solve and show your full codes Write a script file Ask the user to enter sides of a triangle: a, b, c Check to see if the sides are all greater than 0 If they are: Use the function (triangle) that you created in your last homework problem (HW#5 problemttF) to calculate the area. command Display the results on the screen using fprintf write the results to disk using the fprintf command. If any of the...

  • Create a MIPS program that does the following: 4. Determine the letter grade a. Use the...

    Create a MIPS program that does the following: 4. Determine the letter grade a. Use the floating point calculated average to determine the letter grade. You will need to research the instructions to use to do comparisons with floating point numbers. (see Course Resources) b. Use the following chart: 90 - 100 80 - 89 70 - 79 ............. 60 - 69.............. <60 ..................... ............... 5. Display a message and the letter grade. 6. Your output should look similar to...

  • We want to create a program which prints off what letter grade an individual receives based...

    We want to create a program which prints off what letter grade an individual receives based upon whether or not their grade obeys the following condition: grade>= 90 and grade = 80 and grade<89, we will print off “You made a B”, so on and so forth. In this program, we can assume that we are asking the user to enter whatever grade they recieved as a numeric input. NEED HELP WITH ALL PARTS! 4.) Consider the example of grades...

  • #write a function with int parameter to return letter grade for integer score # complete the...

    #write a function with int parameter to return letter grade for integer score # complete the code below: def grader(int1): grade = '' if int1 >=90: grade = 'A' elif int1 >=80: grade = 'B' elif int1 >=70:

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT