# MATLAB: How to let user enter student id and show the final marks

homeworkinputno attempt

Download the ENG1060studentmarks.txt file. The file contains the following information: 1. Column 1: Student ID 2. Column 2—11: Lab marks (/10) worth 2% each (20% total of final grade) 3. Column 12: Assignment mark (/10) worth 10% of the final grade 4. Column 13: Exam mark (/100) worth 70% of the final grade a) Write a function that accepts a student’s laboratory, assignment and exam marks as inputs to determine the final mark to the nearest integer and the letter grade of the student. Your function header would be similar to: function [final_mark, grade] = markscalc(lab, assignment, exam) Note: The letter grades should be stored as a string’ and are described as follows: final_mark ≥ 80 70 ≤ final_mark < 80 60 ≤ final_mark < 70 50 ≤ final_mark < 60 final_mark < 50 → HD → D → C → P →F
Write an m-file that achieves the following: 1. Prompts the user to input a student’s ID number and extracts the individual assessment marks from the ENG1060studentmarks.txt file. 2. Use the function written in part a) to calculate the student’s final mark and letter grade. Hint: You may want to use logical statements or the find() command to determine the row of the ID number which was input by the user.

You may refer to the following two functions and create the actual ones.
function y= get_marks(id)% Gives the marks against the student idload markspos=find(marks(:,1)==id,1);y=[marks(pos,2) marks(pos,3) marks(pos,4)];endfunction [final_mark, grade]=markscale(input)%calculates the total marks and gradefinal_mark=0.1*input(1)+0.2*input(2)+0.7*input(3);if(final_mark>50)     grade='pass';else grade='fail';endend
Here I have stored the marks in a mat file called 'marks' which has a variable 'marks' inside it. However, if you are using a text file you may read data using 'fscanf' function.
To generate a random matrix for marks I have used the following code.
 marks(:,1)=1:10; marks(:,2)=randi([1 100],10,1); marks(:,3)=randi([1 100],10,1); marks(:,4)=randi([1 100],10,1);`
Here the first column is student id and the rest three columns are the marks.