Using MATLAB, prompt the user to enter a vector containing 3 elements that correspond to the scores a student received in three exams. Compute the average of the scores. If the average is less than 60, send a message to the command window telling the user that the student did not pass the course. Otherwise, send a message to the command window telling the user that the student has passed the course.
v = input("Enter vector of 3 values: ");
if mean(v) < 60
disp("You did not pass the course.");
else
disp("You passed the course.");
end
The above code in matlab takes the input from user in form of vector and calculates the mean of the vector. If the mean is less than 60, then it displays You did not pass the course else it displays You passed the course
OUTPUT 1:
Enter vector of 3 values: [60 80 61]
You passed the course.
OUTPUT 2:
Enter vector of 3 values: [40 60 50]
You did not pass the course.
Get Answers For Free
Most questions answered within 1 hours.