0% found this document useful (0 votes)
61 views4 pages

Fall 2023 - MTH643 - 2

This document provides instructions for Assignment 2 for the course MTH643. Students are asked to complete several tasks in MATLAB: 1) Create a script that takes user input for name and student ID and saves values to variables, 2) Save the last 4 digits of the student ID to variables a-d, 3) Create a function to sum variables a-d and save to S, 4) Create a function to check if S is even or odd and save to E_O, 5) Call the functions in the script and print a sentence with the results. Students then take screenshots of the script, functions, and output to paste into a provided answer sheet for submission.

Uploaded by

Ali khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views4 pages

Fall 2023 - MTH643 - 2

This document provides instructions for Assignment 2 for the course MTH643. Students are asked to complete several tasks in MATLAB: 1) Create a script that takes user input for name and student ID and saves values to variables, 2) Save the last 4 digits of the student ID to variables a-d, 3) Create a function to sum variables a-d and save to S, 4) Create a function to check if S is even or odd and save to E_O, 5) Call the functions in the script and print a sentence with the results. Students then take screenshots of the script, functions, and output to paste into a provided answer sheet for submission.

Uploaded by

Ali khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MTH643 Assignment 2 - Due Date: January 15, 2024 Fall 2023

(Please go to Page 3 for the instructions and the Question of this Assignment.)

Student’s Answer Sheet

Student Name: Dummy Student


Student ID: MC210345678

Paste script file assignment2 in this box.

Paste function file SumDigits in this box.

Paste function file EvenOdd in this box.

Paste output file from Command Window in this box.

Assignment # 02 MTH643 (Fall 2023)

Total Marks: 10 Due Date: 15-01-2024


DON’T MISS THESE: Important instructions before attempting the solution and submission of this
assignment:
 Lectures 7-11 are encompassed in Assignment 2.

 All students (of both sections) shall complete this Assignment.

 All your answers, such as name, student ID, and MATLAB script, functions and output files must
be put inside the allocated boxes (fields) provided in the Student’s Answer Sheet.

 Only the Student’s Answer Sheet will be marked. So, you may choose to only upload your
Student’s Answer Sheet. Answers written outside of the boxes may get Zero mark.

Page 1 of 4
MTH643 Assignment 2 - Due Date: January 15, 2024 Fall 2023
 Any copied work, for example, script, functions, and output of some other student’s ID will get
Zero mark.

 Assignment 2 is due on January 15, 2024.

 Properly Upload the Student’s Answer Sheet completed in MS Word format on LMS as per the
previous practice.

QUESTION: OPEN MATLAB SOFTWARE AND PERFORM THE FOLLOWING STEPS:


a. Create a new script file and name it assignment2.
b. Take an input from the user asking the user What is your full name: and save the input in
a variable Name.
c. Take an input from the user asking the user What is your complete student ID: and save
the input in a variable StudentID.
d. Save the last four digits of your student ID in the variables a, b, c and d. For example, a
student having ID MC210345678 will a=5, b=6, and so on.
e. Create a new function file and name it SumDigits. This function will take four input
parameters: a, b, c, d and will give one output parameter: S. The task of this function is to
add the variables a, b, c, d and to save the sum in the variable S.
f. In your assignment2 script file, call the function SumDigits passing the input parameters
a, b, c, d to the function and store the output parameter (S) of the function in a variable
Sum_of_digits.
g. Create a new function file and name it EvenOdd. This function will take one input
parameter Sum_of_digits and will give one output parameter: E_O. The task of this function
is to check if the variable Sum_of_digits is an even number or an odd number and to save
the word Even or Odd in the variable E_O.
h. In your assignment2 script file, call the function EvenOdd passing the input parameter
Sum_of_digits to the function and store the output parameter (E_O) of the function in a
variable Sum_even_or_odd.
i. Finally using fprintf command generate the following sentence:
Sum of digits is 26 and the Sum is Even.
Note: This sum of 26 and the Even is for a dummy Student ID: MC210345678. You will do
all your work with your actual student ID.
j. Run the script to verify that everything runs right. When it prompts your name, write your
name and press enter. When it prompts your student ID, write your student ID and press
enter. Now you will get the output of your work.
(continued to next page)
AND THEN:
 Take a screenshot of the script file assignment2; copy and paste the screenshot in the
box titled: Paste script file assignment2 in this box.
 Take a screenshot of the function file SumDigits; copy and paste the screenshot in the
box titled: Paste function file SumDigits in this box.
 Take a screenshot of the function file EvenOdd; copy and paste the screenshot in the
box titled: Paste function file EvenOdd in this box.
 Take a screenshot of the output file you obtain in the Command Window; copy and
paste the screenshot in the box titled: Paste output file from Command Window in this
box.
VERY IMPORTANT NOTE:
 The screenshots must be taken from MATLAB software. These screenshots must be
taken along with their MATLAB headings and boundaries. See the sample below and
your screenshot must be the same as provided in the sample below.

Page 2 of 4
MTH643 Assignment 2 - Due Date: January 15, 2024 Fall 2023
 Any student who will copy the commands from script, functions or output files and
paste them in the answer boxes instead of pasting the screenshots will be awarded zero
mark.

A sample of Student’s Answer Sheet:


 Please find below a sample Student’s Answer Sheet for a dummy Student ID: MC210345678.
 You will do all your work with your actual student ID. Otherwise; you may get Zero mark.
 Any student using this sample as his/her answer will also get Zero mark.

(continued to next page)

Page 3 of 4
MTH643 Assignment 2 - Due Date: January 15, 2024 Fall 2023

Page 4 of 4

You might also like