In: Computer Science
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.
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
========================================================