3- It will be important to understand how random numbers are generated using the
ID: 3733012 • Letter: 3
Question
3- It will be important to understand how random numbers are generated using the rand) function. You will also need to have a basic understanding of a while or for loop. You are to write a program in which the user tries to guess which number (from 0 to 99, inclusive) that the program generates, based on the rand() function. First the program asks the user to guess which number will be generated, and if the user is correct, it prints "Good guess! and if the user is incorrect, it prints "Sorry too high or too low (depend of the case), try again" Some other specifications: 1. The program should repeatedly ask the user for a guess and generates the outputs "Number picked:"followed by the number, and the statements as to whether it was correct or not, too high or too low. If the user enters a number of 0 or less, the program should print "Goodbye" and exit. 2. mber greater than 99, the program should output "Number too high, If the user enters a nu guess again!" and then ask for another number. When the answer 99 and ask for a new guess. 3. 4. s correct the program must generate a new random number between 1 andExplanation / Answer
disp("Number Picked:" );
disp(x);
i=0;
while(i>0)
if (x<0)
disp("Goodbye");
exit
elseif (x>99)
disp("Number too high,guess again!");
exit
else
if(x==r)
disp("Good guess!")
elseif( x>r)
disp("Sorry too high")
else
disp("Sorry, too low")
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.