# Coding Dojo – Kata Calculator Story Cards

For our last two code dojos, we have done Kata Calculator. We structured it such that the coders got one requirement at a time, broken into multiple groups. Here are the story cards.

White cards

• Calculator should be able to multiply two numbers (10 * 8 = 80)
• Calculator should be able to operate on positive decimal numbers (2.7+1.35=4.05). Numbers less than 1 start with a leading 0.
• Calculator should be able to add two positive integers (2+3=5)
• Calculator should be able to subtract two numbers (6-5=1)

Red cards

• Calculator should round all output to 10 decimal places but only display the minimum number of places to represent the number (eg, 1.2 good, 1.200 bad)
• Calculator should be able to handle simple trigonometry operators: cosine, sine, and tangent. The number passed to the operator is in “radians” like Java’s built-in library (sin(0)=0)
• Calculator should be able to operate on more than two numbers, assuming that precedence is left to right and that multiplication has higher precedence than addition or subtraction (3+4*5-6=17)
• Calculator should be able to handle the constant PI. You should use “PI” as the term. (PI*0=0)

Yellow cards

• Calculator should be able to interpret parentheses. Parentheses behave like they do in math formulas, where they “bracket” operations and operate with “highest” precedence.
• Calculator should be able to divide numbers. Division has the same operator precedence as multiplication. (4+1/3=4.3333333333)
• Calculator should be able to handle the summation of a series of integers, where we sum from the first number to the second number, inclusive. (sum(4,10)=49)

Blue cards

• Calculator should handle negative numbers. A negative number is represented by an initial “-“. (7*-5)–4=-31)
• Calculator should support an optional third parameter for the sum() function that specifies a formula to calculate for each element in the series. The character “y” is used as the formula variable. (sum(1,10,2*y)=110)
• Calculator should handle dividing by 0, by propagating the string “NaN” to the output (6*(5/0)+4)/7=NaN)
• Calculator should be able to handle hexadecimal input for numbers. Output remains in base 10. (5*0xAF=875)