Will you pass the skill check?
In a role playing game a player must perform a skill check if they want to succeed in an action they are attempting. Skill checks are performed with a twenty sided dice. The player has a skill (e.g. dexterity) and a modifier (to reflect any advantages or disadvantages in the situation). The skill and modifier are both integers. The skill, plus the dice roll, plus the modifier (which could be a negative number) must be more than a value decided by a "dungeon master" (the DM value) to succeed.
Write a program to output the result of a skill check. The user enters the skill value, the modifiers value and the number needed to pass. A roll of 1 is always a fail and a roll of 20 is always a success before skill and modifiers are taken into account. If the skill value, plus the modifiers is greater than equal to the number required to pass, the skill check is passed.
Use this boilerplate code as a starting point:
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
Enter the skill value: 15
Enter any modifiers: 2
Enter the number to pass: 12
Automatic pass
Enter the skill value: 6
Enter any modifiers: -1
Enter the number to pass: 14
You rolled a 20
Critical success
Enter the skill value: 10
Enter any modifiers: 2
Enter the number to pass: 20
You rolled a 13
Check passed
Enter the skill value: 9
Enter any modifiers: -2
Enter the number to pass: 13
You rolled a 3
Check failed
Use these resources as a reference to help you meet the success criteria.
Run the unit tests below to check that your program has met the success criteria.
Enter the skill value: 15
Enter any modifiers: 2
Enter the number to pass: 12
Automatic pass
Enter the skill value: 9
Enter any modifiers: -2
Enter the number to pass: 13
You rolled a 3
Check failed
Enter the skill value: 10
Enter any modifiers: 2
Enter the number to pass: 20
You rolled a 13
Check passed
Enter the skill value: 6
Enter any modifiers: -1
Enter the number to pass: 14
You rolled a 20
Critical success
Check that you have: