The user gets 3 tries to guess the lucky number set the luck

The user gets 3 tries to guess the lucky number (set the lucky number = 4) Write generalized code (i.e. if I want to change the lucky number value, I change it at only one location within the program) The user is prompted to enter a number between 1 and 10 The entered number is compared to the lucky number, if it is equal to the lucky number, tell the user that they guessed the correct number, if not tell them to guess again. After each guess, tell them how many guesses they have left. Store all the user guesses in a matrix called \'user_guesses\'. At the end of the game display the numbers guessed by the user. The user gets as many tries as required to guess the lucky number (set the lucky number =4) Write generalized code The user is prompted to enter a number between 1 and 10 The entered number is compared to the lucky number, if it is equal to the lucky number, tell the user that they guessed the correct number, if not tell them to guess again. When they eventually guess the correct number, tell them how many tries it took them to guess the correct number.

Solution

As per the chegg policy I am ding top 3 questions:

Lucky Number code in matlab:

function l= luckyNum(n)
if n==4
l=1;
else
l=0;
end

end

-----------------------

Prompt=\'Enter a number between 1 to 10\';
x=input(Prompt,\'s\');
y=luckyNum(x);
if y==1
disp(\'you have entere a lucky number\');
else
disp(\'you have not entere a lucky number, guess again\');
end

 The user gets 3 tries to guess the lucky number (set the lucky number = 4) Write generalized code (i.e. if I want to change the lucky number value, I change it

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site