Question

In: Computer Science

Please do this in MATLAB with the if-else conditions . You are playing an RPG game....

Please do this in MATLAB with the if-else conditions .

You are playing an RPG game. Currently your experience points (XP) total is equal to experience. To reach the next level your XP should be at least at threshold. If you kill the monster in front of you, you will gain more experience points in the amount of the reward.

Given values experience, threshold and reward, check if you reach the next level after killing the monster.

Solutions

Expert Solution

Please make sure to save the code in a matlab file before executing.

Screenshots for code and output are provided

If you have any doubts or issues , feel free to ask in comments

Please give this answer a like, or upvote. This will be very helpful for me.

===========================================================

Screenshots of code:


Screenshots of output:

Code to copy:

% to clear the screen
clc;

% value of current level
experience_points = 50;

% to clear the screen
clc;

% thresold value
threshold = 70;

% reward value
reward = 30;


fprintf('XP : %d\n', experience_points);
disp("---Press Any key to kill the monster---");

% pause until a key is pressed
pause;

% display result
disp("*** You have killed the monster! ****");

% add reward to XP
experience_points = experience_points + reward;

% print new XP
fprintf('XP : %d\n', experience_points);

% checking if reached new level using if else statments
if experience_points >= threshold
disp("Congratulations , You have reaced a new level !");
else
disp("You have not reached a new level");
  
end

========================================================
  


Related Solutions

Suppose you are playing a game with a friend in which you bet ? dollars on...
Suppose you are playing a game with a friend in which you bet ? dollars on the flip of a fair coin: if the coin lands tails you lose your ? dollar bet, but if it lands heads, you get 2? dollars back (i.e., you get your ? dollars back plus you win ? dollars). Let ? = "the amount you gain or lose." (a) What is the expected return ?(?) on this game? (Give your answer in terms of...
MATLAB, if-else Write a script which to do the following. Take an array of any size...
MATLAB, if-else Write a script which to do the following. Take an array of any size as input and check if all the elements are integers. (i) If not, display the error message ‘Invalid input!’. Use the error command to create a proper error message in red. (ii) If yes, count the number of rows where the sum of the elements is smaller than the average row sum. It is recommended that you use a test variable with many rows...
6. You are playing a card game with a friend. You are using a new deck...
6. You are playing a card game with a friend. You are using a new deck of 52 playing cards and you’d like to calculate some probabilities to improve your game. (Remember, the total number of cards decreases by 1 every time you draw a card!) a. What is the probability of drawing three queen cards in a row? b. What is the probability of drawing all four aces in a row? c. What is the probability of drawing the...
6. You are playing a card game with a friend. You are using a new deck...
6. You are playing a card game with a friend. You are using a new deck of 52 playing cards and you’d like to calculate some probabilities to improve your game. (Remember, the total number of cards decreases by 1 every time you draw a card!) a. What is the probability of drawing three queen cards in a row? b. What is the probability of drawing all four aces in a row? c. What is the probability of drawing the...
You and a friend are playing a game. You alternate turns rolling a single die, and...
You and a friend are playing a game. You alternate turns rolling a single die, and the first person to roll a 1 or a 2 wins. Your friend goes first. a. What’s the probability that the game ends in three rolls or fewer? b. What’s the expected number of rolls? c. What’s the probability that your friend wins?
You are playing a version of the roulette game, where the pockets are from 0 to...
You are playing a version of the roulette game, where the pockets are from 0 to 10 and even numbers are red and odd numbers are black (0 is green). You spin 3 times and add up the values you see. What is the probability that you get a total of 15 given on the first spin you spin a 2? What about a 3? Solve by simulation and analytically.
Please answer to the point and accurate and please do not copy someone else.. Please don't...
Please answer to the point and accurate and please do not copy someone else.. Please don't go for length, 200-300 words will be fine but please very accurate and very careful. I will be very much thankful. I am preperation for exam and it is tough for me. 1. Explain why companies do not consolidate all subsidiaries
Suppose you are playing a dice game and you have three options to find a score....
Suppose you are playing a dice game and you have three options to find a score. The options are: A. Rolling an 11-sided die and using the outcome as your score.* B. Rolling two 4-sided dice, adding 1 to their sum, and using that number as your score. C. Rolling two 4-sided dice, doubling the result of the first die and adding it to the result of the second, subtracting 1 from this result, and using this number as your...
Suppose you are playing a dice game and you have three options to find a score....
Suppose you are playing a dice game and you have three options to find a score. The options are: Rolling an 11-sided die and using the outcome as your score.* Rolling two 4-sided dice, adding 1 to their sum, and using that number as your score. Rolling two 4-sided dice, doubling the result of the first die and adding it to the result of the second, subtracting 1from this result, and using this number as your score. Assume that each...
You are playing a dice game with your friend and he seems to be cheating (either...
You are playing a dice game with your friend and he seems to be cheating (either that or you are really bad at this game). You deduce that the dice is not fair. This is, you expect each of the outcomes to be equally likely, but they do not seem to be coming up that way. In order to prove your point, you record the outcomes of 120 different die rolls and obtain the following frequencies. Run a hypothesis test...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT