Question: 2- It will be important to understand how random numbers are generated using the rand() function. You will also need to have a basic understanding

 2- It will be important to understand how random numbers are

2- 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 (look for file "Ch08_LogicalFunctionsTotal "in D2L->contents->Matlab Presentation and HW You are to write a program in which the user tries to guess which number (from 1 to 7, inclusive) that the program generates, based on the rand() function. The 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, try again!" Some other specifications: 1. The program should repeatedly ask the user for a guess, and repeatedly generates a new random number between 1 and 7, and outputs "Number picked: "followed by the number, and the statements as to whether it was correct or not. 2. 2. If the user enters a number of 0 or less, the program should print "Goodbye" and exit. 3. If the user enters a number greater than 7, the program should output "Number too high, guess again!" and then ask for another number. In this last case, no new random number should be generated. Below is a sample output from an execution of the program. In the sample output examples that follow the user input appears after the colon character () and is followed by the enter key Guess a number from 1to 7 (-0 to quit):5 Number picked: 2 Sorry, try again! Guess a number from 1 to 7 (-0 to quit): 7 Number picked: 7 Good guess! Guess a number from 1to 7 (-0 to quit):4 Number picked: 4 Good guess! Guess a number from 1 to 7 (

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!