Let us worry about your assignment instead!

We Helped With This MATLAB Programming Homework: Have A Similar One?

SOLVED
CategoryProgramming
SubjectMATLAB
DifficultyUndergraduate
StatusSolved
More InfoWrite My Matlab Homework
11991

Short Assignment Requirements

My prof. gave us a problem with 3 steps. I am done with step two.Now I just need to modify the program from the step 2 and solve the last step.Please see the attached file from the step 2 and new instruction for the step 3.

Assignment Description

Mini Project – Guess My Number Game (Step 2)

% Guess a number

clc;

% Generate a number from 1 to 1000

integer=ceil(rand(1)*1000);

% Store the number of guesse made

numGuesses=0;

% Chouse your number

fprintf('I have a number between 1 and 1000 ');

guess=-1;

while (guess~=integer)

    % increment the number of guesses

    numGuesses=numGuesses+1;

    % Get user input

    guess=input('Guess what it is: ');

    % Tell the use about their guess

    if guess>integer

        if (guess-integer)>100

            fprintf('Too large ', guess);

        elseif (guess-integer)>10 & (guess-integer)<=100

            fprintf('Close. Make it smaller ', guess);

        elseif (guess-integer)<=10

            fprintf('Very close now. Make it a little bit smaller ', guess);

        end

    elseif integer>guess

        if (integer-guess)>100

            fprintf('Too small. ', guess);

        elseif (integer-guess)>10 & (integer-guess)<100

            fprintf ('Colose. Make it larger. ', guess);

        elseif (integer-guess)<10

            fprintf ('Very close now. Make it a little larger. ', guess);

        end

    else

        fprintf('Yes! You guessed the correct number in %d shots. ', numGuesses);

    end

end

fprintf('My number is %d. ',integer);

 

 

>>GuessNumber

I have a number between 1 and 1000

Guess what it is: 500

Close. Make it smaller

Guess what it is: 250

Too small.

Guess what it is: 300

Too small.

Guess what it is: 400

Colose. Make it larger.

Guess what it is: 450

Colose. Make it larger.

Guess what it is: 475

Colose. Make it larger.

Guess what it is: 490

Very close now. Make it a little bit smaller

Guess what it is: 485

Very close now. Make it a little larger.

Guess what it is: 487

Very close now. Make it a little bit smaller

Guess what it is: 486

Yes! You guessed the correct number in 10 shots.

My number is 486.

 

Assignment Description

Guess-My-Number Game --- Final Step

Objective:

The purpose of this step of the project is to practice nested loops and gain more experience on loops, particularly how to control the execution flow of loops.  Requirement:

Further improve your MatLab program GuessNumber.m. The program in step 2 terminates after the user provides a guess matching the integer. If the user wants to play another round, she must execute the program again. In this step, after the improvement, your program can allow the user to continue playing after each round without re-executing the program. Specifically, after each round, the user is asked whether she wants to play another round or not. If the answer is yes (Y), the program generates another random integer and asks the user to make guesses. Otherwise, the program terminates.

With the program in step 2, the user has to keep guessing until the integer is guessed. With another improvement, the program in this step will allow user to start another round without finishing the current round (i.e., the user has not guessed the integer generated for this round). Specifically, if the user provides a non-positive guess (0 or negative), the program finishes this the existing round and starts a new round.  Sample Inputs and Outputs:

>> GuessNumber

I have a number between 1 and 1000. Guess what it is: 500 Too small.

Guess what it is: 750 Too big.

Guess what it is: 625

Very close now. Make it a little bit larger.

Guess what it is: 630

Very close now. Make it a little bit larger.

Guess what it is: 633

Yes! You guessed the integer in 5 shots. 

My number is 633.

Do you want to play one more round? (Y/N) Y I have a number between 1 and 1000. Guess what it is: 500 Too big.

Guess what it is: 250 Too big.

Guess what it is: 125 Close. Make it smaller.

Guess what it is: 75 Close. Make it larger.

Guess what it is: 100

Very close now. Make it a little bit smaller.

Guess what it is: 95

Very close now. Make it a little bit larger.

Guess what it is: 97

Very close now. Make it a little bit larger. Guess what it is: 0 My number is 98.

Do you want to play one more round? (Y/N) Y I have a number between 1 and 1000.

Guess what it is: 0

Do you want to play one more round? (Y/N) N

 

Instruction 1) Program 

The existing program in step 2 is to play one round of the game. To allow the user to play more than one round, you need to improve the program and put it into another loop. But, you need to solve the following problems in the new program:

1.       How to control the loop, such that the loop continues if the user wants to play another round? 

In your program, after each round, it asks the user whether she wants to play another round. Specifically, the program can call input function to allow the user to express her option. In the input call, with a message, you need to instruct the user how to express the option. For example, letter Y means yes; and letter N means no. Or, number 1 means yes, number 0 means no. You can define your way to express yes or no. Then you need to examine the input of the user, and decide whether the loop should continue or not.

2.       How to terminate the current round?  Consider to use break statement.

The program skeleton is as follows. Note that some lines are pseudo-code and ellipses represent unfinished parts. You need to replace them with real code.

Note that the program skeleton is just a suggestion. It is totally OK if you follow other structures or use other methods.

 

moreround = true; while moreround == true  % play one round of the game

% break statement is not shown

    … option = input('Do you want to play one more round? (Y/N) ', 's');  if option …     moreround = … end end

 

2)       Testing

If you have tested your program thoroughly in step 2, you want to test only the new code in this step. To reduce the effort to guess the number in each round, you can first test whether your program can finish a round if you provide a non-positive guess. If this part works, you can finish one round quickly. After one round, you should be able to move to another round. If you cannot continue, fix the problem. Keep doing a few rounds and then choose to stop. Your program should terminates.  

 

3)       Submission and Grading

You need to submit TWO files. One file is your program. The other is a text (.txt) file that contains the commands you used to run your program and the corresponding outputs of your program to show that your program works correctly. You can copy from MatLab command window and paste into the text file. We will review these two files to see if your program really works as required. You will get 25 points for your program and another 15 points for submitting the text file

 

Frequently Asked Questions

Is it free to get my assignment evaluated?

Yes. No hidden fees. You pay for the solution only, and all the explanations about how to run it are included in the price. It takes up to 24 hours to get a quote from an expert. In some cases, we can help you faster if an expert is available, but you should always order in advance to avoid the risks. You can place a new order here.

How much does it cost?

The cost depends on many factors: how far away the deadline is, how hard/big the task is, if it is code only or a report, etc. We try to give rough estimates here, but it is just for orientation (in USD):

Regular homework$20 - $150
Advanced homework$100 - $300
Group project or a report$200 - $500
Mid-term or final project$200 - $800
Live exam help$100 - $300
Full thesis$1000 - $3000

How do I pay?

Credit card or PayPal. You don't need to create/have a Payal account in order to pay by a credit card. Paypal offers you "buyer's protection" in case of any issues.

Why do I need to pay in advance?

We have no way to request money after we send you the solution. PayPal works as a middleman, which protects you in case of any disputes, so you should feel safe paying using PayPal.

Do you do essays?

No, unless it is a data analysis essay or report. This is because essays are very personal and it is easy to see when they are written by another person. This is not the case with math and programming.

Why there are no discounts?

It is because we don't want to lie - in such services no discount can be set in advance because we set the price knowing that there is a discount. For example, if we wanted to ask for $100, we could tell that the price is $200 and because you are special, we can do a 50% discount. It is the way all scam websites operate. We set honest prices instead, so there is no need for fake discounts.

Do you do live tutoring?

No, it is simply not how we operate. How often do you meet a great programmer who is also a great speaker? Rarely. It is why we encourage our experts to write down explanations instead of having a live call. It is often enough to get you started - analyzing and running the solutions is a big part of learning.

What happens if I am not satisfied with the solution?

Another expert will review the task, and if your claim is reasonable - we refund the payment and often block the freelancer from our platform. Because we are so harsh with our experts - the ones working with us are very trustworthy to deliver high-quality assignment solutions on time.

Customer Feedback

"Thanks for explanations after the assignment was already completed... Emily is such a nice tutor! "

Order #13073

Find Us On

soc fb soc insta


Paypal supported