This lab introduces you to using <iomanip>
and <cmath>
in C++ for output formatting and mathematical computation. You will write a program that calculates magic max hit values in Old School RuneScape, organizing the results into a neatly formatted table using output manipulators like setw
, setfill
, and justification directives (left
, right
).
Beyond this example, the same skills apply in real-world programming careers, especially in game development. Designers and analysts often need to generate and present tables of stats—damage values, probability charts, or balancing metrics—for their team leads or bosses. Mastering formatted output now gives you the ability to clearly communicate complex calculations later in a professional setting.
You will:
Use the magic max hit formula to compute max hits:
Use these spells and base damage values:
Spell | Base Damage |
---|---|
Fire Bolt | 12 |
Fire Blast | 16 |
Fire Wave | 20 |
Enter your Magic level: 70 Enter your Magic bonus: 25 Spell BaseDmg Level Bonus MaxHit ---------------------------------------------- Fire Bolt 12 70 25 22 Fire Blast 16 70 25 30 Fire Wave 20 70 25 38
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.
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.