Create a new MATLAB Script file named MT3P3_itname.m.
In your script file perform the following calculations:
Prompt the user to enter an integer.
Use a multiple if-elseif structure to determine the following:
Confirm that the number is an integer. If not, the program displays message 1.
Check if the number is divisible by 2 and displays message 2.
Check if the number is divisible by 3 and displays message 3.
For anything other than 1, 2, or 3, the program displays message 4.
Messages:
'xx is not an integer'
'xx is divisible by 2'
'xx is divisible by 3'
'xx is an integer, but not divisible by 2 or 3'
NOTE: to check if a number is an integer, you can check if round(number) is equal to the original number or you can use the rem function.
NOTE: to check if a number is an integer or divisible by 2, or 3, you can check if round(number/#) is equal to the original number or you can use the rem function.
Code:
x = input("Enter an integer:");
if round(x) != x
fprintf("%.2f is not an integer",x)
elseif rem(x,2)==0
fprintf("%d is divisible by 2",x)
elseif rem(x,3)==0
fprintf("%d is divisible by 3",x)
else
fprintf("%d is an integer, but not divisible by 2 or 3",x)
end
Screenshots:

Output:



Any queries comment please
Thank you:)
Create a new MATLAB Script file named MT3P3_itname.m. In your script file perform the following calculations:...
In your script file perform the following calculations : - Prompt the user to enter in a year. - Use a nested if statement to determine if the year is a leap year by checking the following rules: 1. If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5. 2. If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4. 3. If the year is evenly...
Write a program in a script file that finds the smallest odd integer that is also divisible by 3 and whose cube is greater than 4000. Use a loop in the program. The loop should start from 1 and stop when the number is found. The program should print the message: The required number is: [and then prints the number]
Write a C function named: div() with one local variable: m to prompt the user to enter one integer for the local variable m. When you call the function, it should display one of the following lines: If m is divisible by 9 the function displays the message m is divisible by 9 If m is divisible by 3 and not divisible 9 (e.g. 24) the function displays the message m is divisible by 3 If m is neither divisible...
Write a PowerShell script. Make sure to: Comment your script by including your name, date, and short description what the script does The script receives two arguments/parameters, first one should be a string and the second one an integer number. Both should be passed to the script as (positional) arguments/parameters Check if there are two passed parameters Check if passed parameters are as expected (check if first is string and secondis integer). You can use param() here. Displays on the...
4-6 on matlab
4. Write a program in a script file that determines the real roots of a quadratic equation ax2+bx+c 0 When the file runs, it asks the user to enter the values of the constants a, b, and c. To calculate the roots of the equation the program calculates the discriminant D, given by: D b2-4ac When D 0, the program displays message "The equation has two roots," and the roots are displayed in the next line. When...
Write a Script file ‘run-divisiblity-check·m'. Run a for loop from 1 to 100 with an increment of 1 and using if-else statement print whether the current number in the loop is divisible by 2, 3 or both or neither rem0 command in MATLAB tells the remainder of a variable when divided by a particular number. For instance, if x-3, rem(x, 2) would return 1 and if x-2, rem(x, 2) would be 0 Do a help on rem() command if you...
write a Matlab program ( solve the three questions). please use array and create your own function to check primality Question 1 : [10 points) Write a MATLAB program that will store all the first 1000 prime numbers in an array variable named arr_of_primes. Please note that a prime number is a positive integer that is bigger than or equal to 2 which is divisible only by 1 and itself. Examples of the first 8 primes are: 2, 3, 5,...
In this exercise, you will create a script called file_ops.sh that uses the various file operators The file_ops.sh script will Use one command line argument Use four IF THEN statement to compare the first command line argument Determine which file operators to use that produces the following output when the script run with the arguments shown WARNING: In the IF THEN statements, to avoid syntax error messages, there must be a space before and after each bracket and also between...
Instructions: Submit your script in a file named hwk08.m to the dropbox before 11:59 pm on the due date NOTE: This assignment is neither quick nor simple. You will be well served to start on it early, and to ask for help if you need it. Being a more substantial assignment than earlier hwk, it is worth- s. When you ask your calculator for the value of a function for a specified argument, (e.g., sin(22), cos(74), In(6.5)), it almost certainly...
Matlab Question (Matlab Grader) Where indicated at the bottom of the script. write a function, called isright, that takes three inputs, a, b, and c, and determines whether they are could be the lengths of the sides of a right triangle; the output, y, will be set equal to the following: i). -1 if at least one of the values is not positive. Also, only for this case, have the function print out an error message, which states "At least...