Let's Slay Some Monsters

Mon Sep 15 2025
Facebook share linkTwitter/X share linkLinkedIn share linkReddit share linkReddit share link

Introduction

It's time to slay some monsters. You choose a master—Turael, Duradel, or Konar—and that choice governs which monsters are on the table, what the assignment odds look like, and how many you might be sent to defeat. Your program will read the player’s combat and slayer levels, validate that they’re eligible for the chosen master, apply the correct rules (including Duradel’s “halving” twist), and present a clean, aligned table of probabilities and max assignments. Along the way you’ll practice the everyday tools of real programs: careful input handling, selection, and polished console formatting with <iomanip>.

Why this matters: these mechanics map directly to professional work. Eligibility checks, policy- and tier-based behavior, and human-readable reports appear in everything from checkout flows to access control, pricing tiers, and operations dashboards. By turning a game rulebook into code you’ll learn how to translate requirements into precise logic, fail fast with clear messages, and present results stakeholders can trust. Master these habits now and you’ll be faster and safer later—both in this course and on the job.


Task

In Old School Runescape, to gain money and advance combat levels players can get tasks to kill monsters from slayer masters. Players start getting tasks from slayer master Turael, but move on to unlocking slayer masters Duradel and Konar as they advance their combat and slayer levels. Write a program to read a player's combat and slayer levels and what slayer master they want to do, then output a table of the tasks the player may get assigned based on their combat and slayer level. You will need to:

  1. Read the player's combat level as an integer. Use the prompt: "Combat Level: "

  2. Validate combat level:

    • If input fails (non-numeric) print Error: Invalid number and terminate the program.
    • If the combat level is less than 3 print Error: Minimum combat level is 3 and terminate the program.
    • If the combat level is greater than 126 print Error: Maximum combat level is 126 and terminate the program.
  3. Read the player's slayer level as an integer. Use the prompt: "Slayer Level: "

  4. Validate slayer level:

    • If input fails (non-numeric) print Error: Invalid number and terminate the program.
    • If the slayer level is less than 1 print Error: Minimum slayer level is 1 and terminate the program.
    • If the slayer level is greater than 99 print Error: Maximum slayer level is 99 and terminate the program.
  5. Read the player's slayer master choice as a character. Use the prompt:

    (T/t)urael (D/d)uradel (K/k)onar Selection:
  6. Select the slayer master with a switch statement (and validate the choice). Use a switch on the slayer master selection the player previously made to route logic to Turael, Duradel, or Konar. If the selection is not recognized, print Error: Invalid slayer master selection and terminate the program
    Important: You must use a switch for master selection. Not using a switch here will result in a point deduction of 50%.

  7. Inside the switch: Validate master-specific requirements:

    • Duradel requires combat ≥ 100 and slayer ≥ 50; otherwise print Error: Must have combat level 100 and slayer level 50 to visit Duradel and terminate the program.
    • Konar requires combat ≥ 75; otherwise print Error: Must have combat level 75 to visit Konar and terminate the program.
      Important: These validations must be inside the switch cases.
  8. Inside the switch: Set monster task probabilities and max assigned counts. Assign the values below for the selected master. For Duradel, if slayer < 75, print Kill counts halved because of slayer level and halve all max counts (integer division). Important: Assigning probabilities and counts must be performed inside the relevant switch case.

    Slayer MasterKalphite (prob / max)Ankou (prob / max)Dragon (prob / max)Boss (prob / max)Notes
    Turael74%/1524% / 250% / 02% / 1-
    Duradel30% / 12050% / 2500% / 020% / 5If slayer < 75: print halving notice and halve all max counts
    Konar25% / 3035% / 10020% / 10020% / 2-
  9. Output the results table. Print a neatly aligned table with monster (left justified in a width of 10), probability (right justified in a width of 12), and max assigned (right justified in a width of 15) using <iomanip>.


Criteria for Success

See CodeGrade

Example Program Interaction

An example of an interaction with your program is shown below. When interacted with, your program must produce the exact same results.

AS3 % ./a.out Combat Level: error Error: Invalid number

Too small/large combat levels should display similarly with respective errors.

AS3 % ./a.out Combat Level: 10 Slayer Level: 100 Error: Maximum slayer level is 99

Input failure/too small slayer levels should display similarly with respective errors.

AS3 % ./a.out Combat Level: 99 Slayer Level: 99 (T/t)urael (D/d)uradel (K/k)onar Selection: e Invalid slayer master selection
AS3 % ./a.out Combat Level: 99 Slayer Level: 99 (T/t)urael (D/d)uradel (K/k)onar Selection: t Monster Probability Max Assigned ------------------------------------- Kalphite 74% 15 Ankou 24% 25 Dragon 0% 0 Boss 2% 1
AS3 % ./a.out Combat Level: 10 Slayer Level: 50 (T/t)urael (D/d)uradel (K/k)onar Selection: d Must have combat level 100 and slayer level 50 to visit Duradel
AS3 % ./a.out Combat Level: 100 Slayer Level: 50 (T/t)urael (D/d)uradel (K/k)onar Selection: D Kill counts halved because of slayer level Monster Probability Max Assigned ------------------------------------- Kalphite 30% 60 Ankou 50% 125 Dragon 0% 0 Boss 20% 2

See CodeGrade for more examples.

Note: The line breaks after the inputs in the example output formatting above are the ones placed into the terminal by the user hitting enter on their keyboard to input. CodeGrade does not enter values with a keyboard, but rather supplies input via Linux redirection to programs. So in CodeGrade's auto tests there will not be line breaks after the inputs.


Submission Instructions

Save: Save your code as main.cpp. Do not ignore this step or save your file(s) with different names.

Submit: Your program source code must be submitted via CodeGrade as a properly named .cpp file prior to the deadline to receive full credit. Any submissions after the deadline will be subject to the class’ late policy.