 # Answered! Write a MATLAB algorithm and scripts to solve the following question(suggested variable names in brackets). You are required to utilize a switch statement in at least one part of your code.:…

Write a MATLAB algorithm and scripts to solve the following question(suggested variable names in brackets). You are required to utilize a switch statement in at least one part of your code.:

My daughter in grade 4 is actively learning math and needs an “app” to help he check her homework. She is learning addition, subtraction, multiplication and two types of division. She wants this app to

Don't use plagiarized sources. Get Your Custom Essay on
Answered! Write a MATLAB algorithm and scripts to solve the following question(suggested variable names in brackets). You are required to utilize a switch statement in at least one part of your code.:…
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS \$13/PAGE

(a) Ask her the ﬁrst number (a)

(b) Ask her the second number (b)

(c) present her with options of +, -, *, ÷ and ÷ with remainder and ask her to choose one by entering 1, 2, 3, 4, or 5 (op).

(d) Perform the request operation a (op) b and output the entire equation (see Assignment 3 solutions as good example). Keep in mind that in Grade 4 they don’t have decimals or negative numbers yet so:

(a) subtraction is only allowed if the result is not negative, otherwise you should print out an informative message (understandable by the intended user)

(b) division is only allowed if its not “bad” but not only does this mean the second number can not be zero, but that it must also perfectly divide. Each case should have its own descriptive error message

(c) divide with remainder does allow non-perfect division, but must indicate how many times b divided a and what the remainder is (example: 5 ÷ 2 is 2 with a reminder of 1).

prompt = ‘Please enter first number : ‘;

x = input(prompt)

prompt1 = ‘Please enter second input : ‘;
y = input(prompt1)

disp(‘2. Subtraction’);
disp(‘3. Multiplication’);
disp(‘4. Division’);
disp(‘5. Modulus’);

if ch == 1
fprintf(‘Addition of x and y is : %d n’, x+y)
elseif ch == 2
if((x > 0 && y > 0) && (x > y))
fprintf(‘Subtraction of x and y is : %d n’, x-y)
elseif(x < y)
disp(‘1st number is smaller than second number’);
else
disp(‘Negative numbers are not allowed for subtraction’);
end
elseif ch == 3
fprintf(‘Multiplication of x and y is : %d n’, x*y)
elseif ch == 4
if(x > 0 && y > 0)
fprintf(‘Division of x and y is : %d n’, fix(x/y))
else
disp(‘Cannot Perform division with zero’);
end
elseif ch == 5
fprintf(‘Modulus of x and y is : %d n’, mod(x,y))
else
disp(‘Invalid Choice’);
end