Problem 2 (20 Points) Write a MATLAB script, LuckyNumber.m, that asks a user to
ID: 3929284 • Letter: P
Question
Problem 2 (20 Points) Write a MATLAB script, LuckyNumber.m, that asks a user to enter a number (an integer). When a user enters a positive value, the program responds differently depending on whether the entered value is equal to the pre-specified value. When a user enters a negative value, the program responds that the entered value is invalid. Three example sessions are shown below: >> LuckyNumber Enter a number: 2 Incorrect >> LuckyNumber Enter a number: 7 Correct >> LuckyNumber Enter a number: -1 Invalid
(Show Script Please)
Explanation / Answer
pre=7
num=int(input('enter a number :'))
if(num<0)
fprintf("invalid input ")
end
if(num==pre)
frpintf("correct >> lucky number")
else
fprintf("incorrect >> lucky number ")
End