// THIS IS THE ORIGINAL FILE - USE THIS. // ------------------------------------------------------------------------- // Arithmetic Operators - 1 operator - ALL DONE // ---------- // Correctness // Addition, Multiplication // integers // real // mixed-mode: integers & reals // Subtraction // integers // small - large, large - small, equal // real // small - large, large - small, equal // mixed-mode: integers & reals // Division // integers // large / small, small / large, // real numbers // large / small, small / large, // mixed-mode: integers & reals // Modulus // integers // large op small, small op large, equal op equal // real - error # 101 Arithmetic.+.Correct > + // 4 + 5 > Type: expression Hardness: 10 # 102 Arithmetic.*.Correct > * // 3 * 4 > Type: expression Hardness: 10 # 103 Arithmetic.+.Correct > 2.5 + 1.5 > Type: expression Hardness: 10 # 104 Arithmetic.*.Correct > 2.5 * 2.0 > Type: expression Hardness: 10 # 105 Arithmetic.+.{Correct,Coercion} > + 5.5 // 3 + 5.5 > Type: expression Hardness: 20 # 106 Arithmetic.*.{Correct,Coercion} > 3.5 * // 3.5 * 2 > Type: expression Hardness: 20 # 107 Arithmetic.-.Correct > - // 4 - 7 > Type: expression Hardness: 10 # 108 Arithmetic.-.Correct > - // 8 - 5 > Type: expression Hardness: 10 # 109 Arithmetic.-.Correct > - // 6 - 6 > Type: expression Hardness: 10 # 110 Arithmetic.-.Correct > 5.5 - 3.0 > Type: expression Hardness: 10 // # 111 // Arithmetic.-.Correct // > // 2.0 - 4.5 // > // Type: expression // Hardness: 10 // # 112 // Arithmetic.-.Correct // > // 4.0 - 4.0 // > // Type: expression // Hardness: 10 # 113 Arithmetic.-.{Correct,Coercion} > - 3.5 // 7 - 3.5 > Type: expression Hardness: 20 // # 114 // Arithmetic.-.Correct // ? // Arithmetic.-.Coercion // > // 4.5 - // // 4.5 - 6 // // - 6.5 // // 4 - 6.5 // > // Type: expression // Hardness: 20 // # 115 // Arithmetic.-.Correct // ? // Arithmetic.-.Coercion // > // 8 - 8.0 // > // Type: expression // Hardness: 20 # 116 Arithmetic./.Integer.Correct > 7 / 4 > Type: expression Hardness: 20 # 117 Arithmetic./.Integer.Correct > 3 / 6 > Type: expression Hardness: 20 # 118 Arithmetic./.Real.Correct > 6.0 / 4.0 > Type: expression Hardness: 20 # 119 Arithmetic./.Real.Correct > 4.0 / 8.0 > Type: expression Hardness: 20 # 120 Arithmetic./.{Real.Correct,Coercion} > 6.0 / 4 > Type: expression Hardness: 20 # 121 Arithmetic./.{Real.Correct,Coercion} > 2.0 / 4 > Type: expression Hardness: 20 # 122 Arithmetic.%.Correct > % 5 // 7 % 4 > Type: expression Hardness: 20 # 123 Arithmetic.%.Correct > % // 4 % 7 > Type: expression Hardness: 20 # 124 Arithmetic.%.Correct > % // 6 % 6 > Type: expression Hardness: 20 # 125 Arithmetic.%.Real > % // 5.0 % 2 > Type: expression Hardness: 30 # 126 Arithmetic.-.Correct > - // 8 - -5 > Type: expression Hardness: 15 # 127 Arithmetic.-.Correct > - // -5 - 7 > Type: expression Hardness: 15 # 128 Arithmetic.-.Correct > - // -5 - -9 > Type: expression Hardness: 15 # 131 Arithmetic./.Dividing By Zero > / 0 // 8 / 0 > Type: expression Hardness: 15 # 132 Arithmetic.%.Dividing By Zero > % 0 // 5 % 0 > Type: expression Hardness: 15 # 133 Arithmetic.%.Real > % // 2.5 % 6 > Type: expression Hardness: 30 # 134 Arithmetic.%.Real > % // 2 % 6.5 > Type: expression Hardness: 30 # 135 Arithmetic.%.Dividing By Zero > % 0 // 2.5 % 0 > Type: expression Hardness: 30 # 136 Arithmetic.%.Dividing By Zero > % 0 // 2 % 0 > Type: expression Hardness: 30 # 137 Arithmetic.%.Real > 0 % // 0 % 2.5 > Type: expression Hardness: 30 # 138 Arithmetic.%.Correct > 0 % // 0 % 2 > Type: expression Hardness: 30 # 139 Arithmetic./.Real.Correct > 0 / > Type: expression Hardness: 20 # 140 Arithmetic./.Integer.Correct > 0 / > Type: expression Hardness: 20 // Templates for VISUAL BASIC # 141 Arithmetic.^.Correct > ^ 2 > Type: expression Hardness: 30 # 142 Arithmetic.^.Correct > ^ > Type: expression Hardness: 30 # 143 Arithmetic.^.Correct > ^ 0 > Type: expression Hardness: 30 # 144 Arithmetic.^.Correct > ^ 1 > Type: expression Hardness: 30 # 145 Arithmetic.^.Correct > ^ -1 > Type: expression Hardness: 30 // -------------------------------------------------------------------------------- // Introduced to promote understanding of coercion // Note that using real numbers with fractions does not teach // coercion, we need whole real numbers such as 7.0 and 9.0 # 151 Arithmetic.+.{Correct,Coercion} > + 3.0 // + // 7 + 3.0 > Type: expression Hardness: 30 # 152 Arithmetic.+.{Correct,Coercion} > 5.0 + // + // 3.0 + 7 > Type: expression Hardness: 30 # 153 Arithmetic.+.{Correct,Associativity,Coercion} > 5.0 + + // + + // 4.3 + 5 + 3 > Type: expression Hardness: 30 # 154 Arithmetic.+.{Correct,Associativity,Coercion} > + 4.0 + // + + // 4 + 5.3 + 3 > Type: expression Hardness: 30 # 155 Arithmetic.+.{Correct,Associativity,Coercion} > + + 2.0 // + + // 4 + 3 + 5.3 > Type: expression Hardness: 30 # 156 Arithmetic.-.{Correct,Coercion} > - 5.0 // - // 8 - 5.5 > Type: expression Hardness: 30 # 157 Arithmetic.-.{Correct,Coercion} > 9.0 - // - // 7.3 - 5 > Type: expression Hardness: 30 # 158 Arithmetic.-.{Correct,Associativity,Coercion} > 13.0 - - // - - // 12.3 - 5 - 3 > Type: expression Hardness: 30 # 159 Arithmetic.-.{Correct,Associativity,Coercion} > - 3.0 - // - - // 13 - 3.3 - 3 > Type: expression Hardness: 30 # 160 Arithmetic.-.{Correct,Associativity,Coercion} > - - 5.0 // - - // 14 - 3 - 2.3 > Type: expression Hardness: 30 # 161 Arithmetic.*.{Correct,Coercion} > * 3.0 // * // 5 * 4.5 > Type: expression Hardness: 30 # 162 Arithmetic.*.{Correct,Coercion} > 5.0 * // * // 3.3 * 5 > Type: expression Hardness: 30 # 163 Arithmetic.*.{Correct,Associativity,Coercion} > 2.0 * * // * * // 2.3 * 2 * 3 > Type: expression Hardness: 30 # 164 Arithmetic.*.{Correct,Associativity,Coercion} > * 2.0 * // * * // 3 * 2.3 * 3 > Type: expression Hardness: 30 # 165 Arithmetic.*.{Correct,Associativity,Coercion} > * * 1.0 // * * // 4 * 3 * 2.3 > Type: expression Hardness: 30 # 166 Arithmetic./.{Real.Correct,Coercion} > / 2.0 // 8 / 2.0 > Type: expression Hardness: 30 # 167 Arithmetic./.{Real.Correct,Coercion} > 12.0 / // 12.0 / 5 > Type: expression Hardness: 30 # 168 Arithmetic./.{Real.Correct,Associativity,Coercion} > 24.0 / / 2 // 24.0 / 3 / 2 > Type: expression Hardness: 30 # 169 Arithmetic./.{Real.Correct,Associativity,Coercion} > 20 / 2.0 / // 12 / 2.0 / 5 > Type: expression Hardness: 30 # 170 Arithmetic./.{Integer.Correct,Real.Correct,Associativity,Coercion} > / / 2.0 // 7 / 3 / 2.0 > Type: expression Hardness: 30 // ------------------------------------------------------------------------- // Precedence - Two Operators only - ALL DONE // + *, + / (both int and real), + % // - *, - / (both int and real), - % // Error for modulus # 200 Arithmetic.{+.Precedence,*.Precedence} > // + * 3 + 4 * 5 > Type: expression Hardness: 30 # 201 Arithmetic.{+.Precedence,*.Precedence} > + * // 3 + 4 * 5 > Type: expression Hardness: 30 # 202 Arithmetic.{+.Precedence,*.Precedence} > 4.0 + * // 4.0 + 6 * 3 > Type: expression Hardness: 40 # 203 Arithmetic.{+.Precedence,/.Precedence} > + / 6 // 6 + 7 / 3 > Type: expression Hardness: 30 # 204 Arithmetic.{+.Precedence,/.Precedence} > + 7.0 / 4.0 // 5 + 7.0 / 4.0 > Type: expression Hardness: 40 # 205 Arithmetic.{+.Precedence,/.Precedence} > + 4.0 / 8 // 4 + 4.0 / 8 > Type: expression Hardness: 40 # 206 Arithmetic.{+.Precedence,/.Precedence} > 3.5 + 7 / 4 > Type: expression Hardness: 40 # 207 Arithmetic.{+.Precedence,%.Precedence} > + % 5 // 3 + 7 % 4 > Type: expression Hardness: 30 # 208 Arithmetic.{+.Precedence,%.Precedence} > + % // 4.0 + 3 % 8 > Type: expression Hardness: 40 # 209 Arithmetic.{-.Precedence,*.Precedence} > - * // 8 - 2 * 5 > Type: expression Hardness: 30 # 210 Arithmetic.{-.Precedence,*.Precedence} > - 0.5 * // 7 - 1.5 * 2 > Type: expression Hardness: 40 # 211 Arithmetic.{-.Precedence,/.Precedence} > - 4 / 3 // 7 - 4 / 3 > Type: expression Hardness: 30 # 212 Arithmetic.{-.Precedence,/.Precedence} > - 6 / 4.0 // 9 - 6 / 4.0 > Type: expression Hardness: 40 # 213 Arithmetic.{-.Precedence,/.Precedence} > - 2.0 / 8.0 // 7 - 2.0 / 8.0 > Type: expression Hardness: 40 # 214 Arithmetic.{-.Precedence,/.Precedence} > 8.5 - 4 / 6 > Type: expression Hardness: 40 # 215 Arithmetic.{-.Precedence,%.Precedence} > - % // 9 - 4 % 6 > Type: expression Hardness: 30 # 216 Arithmetic.{-.Precedence,%.Precedence} > - % 6 // 8.5 - 8 % 3 > Type: expression Hardness: 40 # 217 Arithmetic.%.Real ? Arithmetic.{%.Precedence,+.Precedence} > + 6.0 % 6 // 5 + 6.0 % 6 > Type: expression Hardness: 30 # 218 Arithmetic.%.Real ? Arithmetic.{%.Precedence,+.Precedence} > + % // 8 + 4 % 8.0 > Type: expression Hardness: 30 # 219 Arithmetic.%.Real ? Arithmetic.{%.Precedence,-.Precedence} > - % // 9 - 4 % 6.5 > Type: expression Hardness: 30 # 220 Arithmetic.%.Real ? Arithmetic.{%.Precedence,-.Precedence} > - % // 7 - 9.0 % 2 > Type: expression Hardness: 30 // ------------------------------------------------------------------------- // Associativity - 2 operators- ALL DONE // + + + // - - - // * * * // / / / // % % % // WHAT ABOUT + -, * /, / %, * %? - Add these!!!!!!!!!!!!!!!!!! # 300 Arithmetic.{+.Associativity,-.Associativity} > + - // 3 + 4 - 5 > Type: expression Hardness: 50 # 301 Arithmetic.+.Associativity > + + // 3 + 4 + 5 > Type: expression Hardness: 50 # 302 Arithmetic.+.Associativity > + + 3.0 // 2 + 5 + 3.0 > Type: expression Hardness: 50 # 303 Arithmetic.-.Associativity > - - 2.0 // 9 - 5 - 2.0 > Type: expression Hardness: 50 # 304 Arithmetic.-.Associativity > - 3.0 - // 11 - 3.0 - 6 > Type: expression Hardness: 50 # 305 Arithmetic.*.Associativity > 2 * * 1.5 // 2 * 3 * 1.5 > Type: expression Hardness: 50 # 306 Arithmetic.*.Associativity > * 1.5 * 2 // 4 * 1.5 * 2 > Type: expression Hardness: 50 # 307 Arithmetic./.Associativity > 12 / 2 / 2 > Type: expression Hardness: 50 # 308 Arithmetic./.Associativity > 16 / 8 / 4 > Type: expression Hardness: 50 # 309 Arithmetic./.Associativity > 10 / 2.5 / 2 > Type: expression Hardness: 50 # 310 Arithmetic./.Associativity ? Arithmetic./.Integer.Correct > 9 / 3 / 2.0 > Type: expression Hardness: 50 # 311 Arithmetic.%.Associativity > % % // 9 % 5 % 2 > Type: expression Hardness: 50 # 312 Arithmetic.%.Associativity > % % // 10 % 6 % 3 > Type: expression Hardness: 50 # 313 Arithmetic.%.Real ? Arithmetic.%.Associativity > % % // 10 % 4 % 6.0 > Type: expression Hardness: 50 # 314 Arithmetic.%.Real > % % // 4 % 6.0 % 6 > Type: expression Hardness: 50 # 315 Arithmetic.%.Real > % % // 15.0 % 5 % 4 > Type: expression Hardness: 50 # 321 Arithmetic./.Dividing By Zero > * / 0 // 4 * 2 / 0 > Type: expression Hardness: 20 # 322 Arithmetic./.Dividing By Zero > / / 0 // 9 / 3 / 0 > Type: expression Hardness: 20 # 323 Arithmetic./.Dividing By Zero > % / 0 // 8 % 5 / 0 > Type: expression Hardness: 20 # 331 Arithmetic.%.Dividing By Zero > * % 0 // 5 * 3 % 0 > Type: expression Hardness: 20 # 332 Arithmetic.%.Dividing By Zero > / % 0 // 6 / 4 % 0 > Type: expression Hardness: 20 # 333 Arithmetic.%.Dividing By Zero > % % 0 // 9 % 6 % 0 > Type: expression Hardness: 20 // ------------------------------------------------------------------------- // Precedence & Associativity - 3 Operators - ALL DONE // + + * (int), + * + (real) // * + * // + + / (int), + / + (real) // / + / // + + % (int), + % + // % + % // - - * (int), - * - (real) // * - * // - - / (int), - / - (real) // / - / // - - % (int), - % - // % - % // % with errors // / + %, / - % // / + *, / - * // * + %, * - % // Divide by Zero errors # 401 Arithmetic.{*.Precedence,+.{Precedence,Associativity}} > + + * // -8 + 5 + 2 * 3 > Type: expression Hardness: 40 # 402 Arithmetic.{*.Precedence,+.{Precedence,Associativity}} > 0.5 + * 2.5 + // 0.5 + 4 * 2.5 + 2 > Type: expression Hardness: 50 # 403 Arithmetic.{+.Precedence,*.{Precedence,Associativity}} > * + * 1.5 // 2 * 4 + 2 * 1.5 > Type: expression Hardness: 50 # 404 Arithmetic.{/.Precedence,+.{Precedence,Associativity}} > + + / 5 // -6 + 4 + 8 / 5 > Type: expression Hardness: 40 # 405 Arithmetic.{/.Precedence,+.{Precedence,Associativity}} > + 4.5 + / 3 // 3 + 4.5 + 8 / 3 > Type: expression Hardness: 50 # 406 Arithmetic.{/.Precedence,+.{Precedence,Associativity}} > + 6 / 4.0 + 0.8 // 3 + 6 / 4.0 + 0.8 > Type: expression Hardness: 50 # 407 Arithmetic.{+.Precedence,/.{Precedence,Associativity}} > 10 / 4 + 10.0 / 4.0 > Type: expression Hardness: 50 # 408 Arithmetic.{%.Precedence,+.{Precedence,Associativity}} > + + % 4 // -8 + 3 + 7 % 4 > Type: expression Hardness: 40 # 409 Arithmetic.{%.Precedence,+.{Precedence,Associativity}} > + % + // 3 + 15 % 7 + 5 > Type: expression Hardness: 40 # 410 Arithmetic.{+.Precedence,%.{Precedence,Associativity}} > 10 % + % 10 // 10 % 3 + 3 % 10 > Type: expression Hardness: 50 # 411 Arithmetic.%.Real > + + % // 6 + 2 + 8.0 % 4.0 > Type: expression Hardness: 60 // This template is tricky: in C# and Java, 10 % 10.0 = 0.0, // interface accepts 0 or 0.0, but subsequent calculations suffer // coercion, which the user may not realize # 412 Arithmetic.%.Real > // + 10 % 10.0 + + 10 % 10.0 + // 4.2 + 10 % 10.0 + 4.2 > Type: expression Hardness: 60 # 413 Arithmetic.%.Real > % + % // 12 % 5 + 5 % 12.0 > Type: expression Hardness: 60 # 414 Arithmetic.{*.Precedence,-.{Precedence,Associativity}} > - - * // 2 - 4 - 2 * 4 > Type: expression Hardness: 40 // # 415 // Arithmetic.{*.Precedence,-.{Precedence,Associativity}} // > // - * - // // 4.5 - 4 * 2 - 2.5 // > // Type: expression // Hardness: 50 # 416 Arithmetic.{-.Precedence,*.{Precedence,Associativity}} > 2.5 * 4 - 4.5 * 2 > Type: expression Hardness: 50 # 417 Arithmetic.{/.Precedence,-.{Precedence,Associativity}} > - 5 - / 5 // 9 - 5 - 9 / 5 > Type: expression Hardness: 40 // # 418 // Arithmetic.{/.Precedence,-.{Precedence,Associativity}} // > // - 3 / 1.5 - 3.5 // // 4 - 3 / 1.5 - 3.5 // > // Type: expression // Hardness: 50 # 419 Arithmetic.{-.Precedence,/.{Precedence,Associativity}} > / - / // 4 / 9 - 9 / 4 > Type: expression Hardness: 50 # 420 Arithmetic.{-.Precedence,/.{Precedence,Associativity}} > / 5.0 - / 5 // 8 / 5.0 - 8 / 5 // / 5 - / 5.0 // 8 / 5 - 8 / 5.0 > Type: expression Hardness: 50 # 421 Arithmetic.{-.Precedence,/.{Precedence,Associativity}} > 15.0 / 6.0 - 15 / 6 > Type: expression Hardness: 50 # 422 Arithmetic.{-.{Precedence,Associativity},%.Precedence} > - - % // 2 - 6 - 2 % 6 > Type: expression Hardness: 40 # 423 Arithmetic.{-.{Precedence,Associativity},%.Precedence} > - % - // 7 - 7 % 4 - 4 > Type: expression Hardness: 40 # 424 Arithmetic.{-.Precedence,%.{Precedence,Associativity}} > % - % // 9 % 5 - 5 % 9 > Type: expression Hardness: 50 # 425 Arithmetic.%.Real > - + % // 6 - 4.0 + 4 % 6.0 > Type: expression Hardness: 60 # 426 Arithmetic.%.Real > - % + // 8 - 5.5 % 2 + 3 > Type: expression Hardness: 60 # 427 Arithmetic.%.Real > % 8.0 - 8 % // 5 % 8.0 - 8 % 5 > Type: expression Hardness: 60 # 428 Arithmetic.{/.{Precedence,Associativity},%.{Precedence,Associativity},+.Precedence} > / + % // 3 / 6 + 3 % 6 > Type: expression Hardness: 50 # 429 Arithmetic.{/.{Precedence,Associativity},%.{Precedence,Associativity},-.Precedence} > / - % // 8 / 5 - 8 % 5 > Type: expression Hardness: 50 # 430 Arithmetic.{/.{Precedence,Associativity},%.{Precedence,Associativity},-.Precedence} > % - / // 6 % 6 - 6 / 6 > Type: expression Hardness: 50 // # 431 // Arithmetic.{/.{Precedence,Associativity},%.{Precedence,Associativity},-.Precedence} // > // / 4.0 - % 4 // // 10 / 4.0 - 10 % 4 // > // Type: expression // Hardness: 50 # 432 Arithmetic.%.Real > % 5.0 - / 5.0 // 9 % 5.0 - 9 / 5.0 > Type: expression Hardness: 60 # 433 Arithmetic.{/.{Precedence,Associativity},*.{Correct,Precedence,Associativity},+.Precedence} > 5 / + * 5 // 5 / 3 + 3 * 5 > Type: expression Hardness: 40 # 434 Arithmetic.{/.{Real.Correct,Precedence,Associativity},*.{Precedence,Associativity},-.Precedence} > 15 / 1.5 - * // 15 / 1.5 - 2 * 2 // 10 / 2.5 - 4 * 2 > Type: expression Hardness: 50 # 435 Arithmetic.{/.{Precedence,Associativity},*.{Precedence,Associativity},+.Precedence} > / + * // 5 / 5 + 5 * 5 > Type: expression Hardness: 40 # 436 Arithmetic.{*.{Precedence,Associativity},%.{Precedence,Associativity},+.Precedence} > * + % // 3 * 3 + 3 % 3 > Type: expression Hardness: 40 # 437 Arithmetic.{*.{Precedence,Associativity},%.{Precedence,Associativity},-.Precedence} > % - * // 7 % 7 - 7 * 7 > Type: expression Hardness: 50 # 438 Arithmetic.{*.{Precedence,Associativity},%.{Precedence,Associativity},-.Precedence} > * 0 - % // 5 * 0 - 15 % 5 > Type: expression Hardness: 50 # 439 Arithmetic.%.Real > * + % // 2 * 3 + 4 % 6.5 > Type: expression Hardness: 60 # 440 Arithmetic.{/.{Precedence,Associativity},-.Precedence} > / - / 0 // 7 / 3 - 5 / 0 > Type: expression Hardness: 50 # 441 Arithmetic.%.Dividing By Zero > - - % 0 // 8 - 6 - 4 % 0 > Type: expression Hardness: 60 # 442 Arithmetic.%.Real > * / 2.0 % // 2 * 3 / 2.0 % 2 > Type: expression Hardness: 60 # 443 Arithmetic.{+.Precedence,/.{Precedence,Associativity,Coercion}} > / 2.0 + 12.0 / // 6 / 2.0 + 12.0 / 3 > Type: expression Hardness: 50 // ------------------------------------------------------------------------- // Precedence & Associativity - 4 or more Operators - // + / - * // * - % + // + / - % // * - / - % // % + / + * # 500 Arithmetic.{+.Precedence,-.Precedence,*.Precedence,/.Precedence} > + / - * // 3 + 10 / 4 - 2 * 3 > Type: expression Hardness: 60 # 501 Arithmetic.{+.Precedence,-.Precedence,*.Precedence,/.Precedence} > * - % + // 3 * 4 - 10 % 3 + 3 > Type: expression Hardness: 60 # 502 Arithmetic.{+.Precedence,-.Precedence,*.Precedence,/.Precedence} > + / - % // 3 + 10 / 4 - 10 % 4 > Type: expression Hardness: 60 # 503 Arithmetic.{+.Precedence,-.Precedence,*.Precedence,/.Precedence} > * - / - % // 3 * 4 - 8 / 4 - 13 % 4 > Type: expression Hardness: 60 # 504 Arithmetic.{+.Precedence,-.Precedence,*.Precedence,/.Precedence} > % + / + * // 16 % 7 + 12 / 3 + 4 * 5 > Type: expression Hardness: 60 // # 998 // Arithmetic // > // {=; * 5 + % 5;} // > // Type: expression // Hardness: 60 // # 999 // Arithmetic // > // 3 * 4 - -5 / 2 <= 10 % 3 // > // Type: expression // Hardness: 60 // -------------------------------------------------------------------------- // Expressions with parentheses // Parenthesis is an operator. // It affects the precedence and associativy of the other operators in an expression. // By itself, it has no meaning, it has meaning only in the context of other operators. // Therefore, Parenthesis will be treated as: // Arithmetic.Parenthesis, Assignment.Parenthesis, etc. // even though this is duplicative.. // This should be understood as: // Arithmetic.Parenthesis.Precedence - how parenthesis affects the precedence of arithmetic operators // Arithmetic.Parenthesis.Associativity - how parenthesis affects the associativity of arithmetic operators // -------------------------------------------------------------------------- // Arithmetic.Parenthesis.Precedence - 600 // Parenthesis always encloses LOWER precedence operator, // preferably the second or third operator # 600 Arithmetic.Parenthesis.Precedence > * ( + ) // 3 * (4 + 5) > Type: expression Hardness: 20 # 601 Arithmetic.Parenthesis.Precedence > - ( - ) // 9 - (6 - 2) > Type: expression Hardness: 20 # 602 Arithmetic.{Parenthesis.Precedence,-.Correct} > - ( - ) // 8 - (4 - 6) > Type: expression Hardness: 25 # 603 Arithmetic.Parenthesis.Precedence > / ( + ) // 12 / (3 + 4) > Type: expression Hardness: 20 # 604 Arithmetic.Parenthesis.Precedence > % ( + ) // 14 % (4 + 3) > Type: expression Hardness: 20 # 605 Arithmetic.Parenthesis.Precedence > * ( - ) // 3 * (8 - 5) > Type: expression Hardness: 20 # 606 Arithmetic.Parenthesis.Precedence > / ( - ) // 17 / (7 - 3) > Type: expression Hardness: 20 # 607 Arithmetic.Parenthesis.Precedence > % ( - ) // 9 % (6 - 4) > Type: expression Hardness: 20 # 608 Arithmetic.{Parenthesis.Precedence,/.Integer.Correct} > / ( / ) // 12 / (7 / 3) > Type: expression Hardness: 20 # 609 Arithmetic.{Parenthesis.Precedence,%.Correct} > % ( % ) // 11 % (5 % 2) > Type: expression Hardness: 20 # 610 Arithmetic.{Parenthesis.Precedence,/.Integer.Correct} > / ( / ) // 7 / (12 / 3) > Type: expression Hardness: 20 # 611 Arithmetic.{Parenthesis.Precedence,%.Correct} > % ( % ) // 3 % (5 % 2) > Type: expression Hardness: 20 # 615 Arithmetic.{Parenthesis.Precedence,*.Associativity,/.Associativity} > * ( + ) / // 3 * (4 + 5) / 2 > Type: expression Hardness: 30 # 616 Arithmetic.{Parenthesis.Precedence,*.Associativity,/.Associativity} > * / ( + ) // 2 * 3 / (4 + 5) > Type: expression Hardness: 30 # 617 Arithmetic.{Parenthesis.Precedence,*.Associativity,%.Associativity} > * ( + ) % // 3 * (4 + 5) % 2 > Type: expression Hardness: 30 # 618 Arithmetic.{Parenthesis.Precedence,*.Associativity,%.Associativity} > * % ( + ) // 2 * 3 % (4 + 5) > Type: expression Hardness: 30 # 619 Arithmetic.{Parenthesis.Precedence,%.Associativity,/.Associativity} > / ( + ) % // 14 / (4 + 3) % 2 > Type: expression Hardness: 30 # 620 Arithmetic.{Parenthesis.Precedence,%.Associativity,/.Associativity} > / % ( + ) // 12 / 3 % (4 + 5) > Type: expression Hardness: 30 // Selected for Integrated/Post-test # 621 Arithmetic.{Parenthesis.Precedence,*.Associativity,/.Associativity} > / ( - ) * // 13 / (7 - 4) * 2 > Type: expression Hardness: 30 // Selected for Integrated/Pre-test # 622 Arithmetic.{Parenthesis.Precedence,*.Associativity,/.Associativity} > / * ( - ) // 12 / 3 * (7 - 5) > Type: expression Hardness: 30 # 623 Arithmetic.{Parenthesis.Precedence,*.Associativity,%.Associativity} > % ( - ) * // 15 % (9 - 5) * 2 > Type: expression Hardness: 30 # 624 Arithmetic.{Parenthesis.Precedence,*.Associativity,%.Associativity} > % * ( - ) // 19 % 5 * (9 - 5) > Type: expression Hardness: 30 # 625 Arithmetic.{Parenthesis.Precedence,%.Associativity,/.Associativity} > % ( - ) / // 16 % (7 - 4) / 2 > Type: expression Hardness: 30 # 626 Arithmetic.{Parenthesis.Precedence,%.Associativity,/.Associativity} > % / ( - ) // 16 % 3 / (6 - 2) > Type: expression Hardness: 30 // ------------------------------------------------------------------------------------ // Arithmetic.Parenthesis.Associativity - 650 // Associativity: // Following are inside-out associativity, important for students to know // op ( op ( op )), op (( op ) op), (op (op)) op, (( op ) op ) op // (low) high (low) // (2 ops) (2 ops) // () () () # 650 Arithmetic.Parenthesis.Associativity > * ( - ( + )) // 4 * (6 - (2 + 3)) > Type: expression Hardness: 30 # 651 Arithmetic.Parenthesis.Associativity > / ( + ( - )) // 14 / (2 + (6 - 3)) > Type: expression Hardness: 30 # 652 Arithmetic.Parenthesis.Associativity > % ( - ( - )) // 14 % (6 - (6 - 3)) > Type: expression Hardness: 30 # 653 Arithmetic.Parenthesis.Associativity > * (( + ) - ) // 4 * ((3 + 3) - 4) > Type: expression Hardness: 30 // Integrated - Pre-test # 654 Arithmetic.Parenthesis.Associativity > / (( - ) + ) // 14 / ((6 - 3) + 2) > Type: expression Hardness: 30 # 655 Arithmetic.Parenthesis.Associativity > % (( + ) - ) // 14 % ((3 + 6) - 2) > Type: expression Hardness: 30 // Integrated - Post-test # 656 Arithmetic.Parenthesis.Associativity > ( + ( - )) * // (3 + (6 - 2)) * 5 > Type: expression Hardness: 30 # 657 Arithmetic.Parenthesis.Associativity > ( - ( - )) / // (6 - (4 - 8)) / 5 > Type: expression Hardness: 30 # 658 Arithmetic.Parenthesis.Associativity > ( + ( + )) % // (3 + (4 + 7)) % 5 > Type: expression Hardness: 30 # 660 Arithmetic.Parenthesis.Associativity > ( + ) * ( - ) // (2 + 6) * (2 - 6) > Type: expression Hardness: 20 # 661 Arithmetic.Parenthesis.Associativity > ( - ) * ( + ) // (6 - 2) * (6 + 2) > Type: expression Hardness: 20 # 662 Arithmetic.Parenthesis.Associativity > ( + ) * ( - ) // (7 + 7) * (7 - 7) > Type: expression Hardness: 20 # 663 Arithmetic.Parenthesis.Associativity > ( + ) / ( - ) // (2 + 6) / (2 - 6) > Type: expression Hardness: 20 # 664 Arithmetic.Parenthesis.Associativity > ( - ) / ( + ) // (6 - 2) / (6 + 2) > Type: expression Hardness: 20 # 665 Arithmetic.Parenthesis.Associativity > ( + ) % ( - ) // (2 + 6) % (6 - 2) > Type: expression Hardness: 20 # 666 Arithmetic.Parenthesis.Associativity > ( - ) % ( + ) // (6 - 2) % (6 + 2) > Type: expression Hardness: 20 # 667 Arithmetic.Parenthesis.Associativity > ( + ) % ( * 2) // (3 + 3) % (3 * 2) > Type: expression Hardness: 20 # 670 Arithmetic.Parenthesis.{Precedence,Associativity} > ( + * ) % ( - / ) // (2 + 3 * 2) % (9 - 7 / 2) > Type: expression Hardness: 30 # 671 Arithmetic.Parenthesis.{Precedence,Associativity} > ( - * ) / ( + % ) // (15 - 3 * 4) / (3 + 15 % 4) > Type: expression Hardness: 30 # 672 Arithmetic.Parenthesis.{Precedence,Associativity} > ( + * ) * ( - * ) // (2 + 2 * 3) * (9 - 3 * 2) > Type: expression Hardness: 30 # 673 Arithmetic.Parenthesis.{Precedence,Associativity} > ( - / ) % ( + * ) // (9 - 9 / 3) % (2 + 2 * 3) > Type: expression Hardness: 30 # 674 Arithmetic.Parenthesis.{Precedence,Associativity} > ( + % ) / ( - * ) // (3 + 9 % 4) / (3 - 3 * 4) > Type: expression Hardness: 30 # 675 Arithmetic.Parenthesis.{Precedence,Associativity} > ( - % ) * ( + / ) // (3 - 3 % 4) * (3 + 4 / 3) > Type: expression Hardness: 30 # 680 Arithmetic.Parenthesis.{Precedence,Associativity} > ( + ) * ( - ) / ( * ) // (2 + 3) * (2 - 3) / (2 * 3) > Type: expression Hardness: 35 # 681 Arithmetic.Parenthesis.{Precedence,Associativity} > ( % ) * ( / ) % ( - ) // (6 % 6) * (6 / 2) % (6 - 2) > Type: expression Hardness: 35 # 682 Arithmetic.Parenthesis.{Precedence,Associativity} > ( * ) / ( + ) % ( / ) // (2 * 3) / (2 + 3) % (6 / 3) > Type: expression Hardness: 35 // // STILL Works! // # 678 // Arithmetic.{Parenthesis.Associativity,%.Precedence} // > // ( % ( - ( - )) + ( * + )) // // (14 % (6 - (6 - 3)) + (4 * 5 + 5)) // > // Type: expression // Hardness: 60 // // // These generate code errors, use these only at the end // # 650 // Arithmetic.{Parenthesis.Precedence,%.Real} // ? // Arithmetic.{%.Precedence,+.Precedence},Parenthesis.Precedence // > // % ( + 2.0) // // 4 % (6 + 2.0) // > // Type: expression // Hardness: 40 // // # 651 // Arithmetic.{Parenthesis.Precedence,%.Real} // ? // Arithmetic.{%.Precedence,-.Precedence},Parenthesis.Precedence // > // % ( - 1.0) // // 4 % (6 - 1.0) // > // Type: expression // Hardness: 40 // // # 652 // Arithmetic.{Parenthesis.Precedence,%.Real} // ? // Parenthesis.Precedence // > // % ( % ) // // 15.0 % (6 % 4) // > // Type: expression // Hardness: 60 // // # 655 // Arithmetic.{Parenthesis.Precedence,/.Dividing By Zero} // ? // Parenthesis.Precedence // > // % ( % ) // // 9 % (3 % 3) // > // Type: expression // Hardness: 30 // // # 656 // Arithmetic.{Parenthesis.Precedence,/.Dividing By Zero} // ? // Parenthesis.Precedence // > // % ( * 0) // // 8 % (5 * 0) // > // Type: expression // Hardness: 30 // // # 657 // Arithmetic.{Parenthesis.Precedence,/.Dividing By Zero} // ? // Parenthesis.Precedence // > // % ( / ) // // 8 % (3 / 7) // > // Type: expression // Hardness: 30 // // # 658 // Arithmetic.{Parenthesis.Precedence,/.Dividing By Zero} // ? // Parenthesis.Precedence // > // / ( % ) // // 9 / (3 % 3) // > // Type: expression // Hardness: 30 // // # 659 // Arithmetic.{Parenthesis.Precedence,/.Dividing By Zero} // ? // Parenthesis.Precedence // > // / ( * 0) // // 8 / (5 * 0) // > // Type: expression // Hardness: 30 // // # 660 // Arithmetic.{Parenthesis.Precedence,/.Dividing By Zero} // ? // Parenthesis.Precedence // > // / ( / ) // // 8 / (3 / 7) // > // Type: expression // Hardness: 30 // -------------------------------------------------------------------------- // // Testing arithmetic operator being applied to boolean operands in C++/Java/C# // # 900 // Arithmetic.+.Correct // > // true + true // > // Type: expression // Hardness: 50 // // // To test unary and binary operators // # 901 // Arithmetic.+.Correct // > // + + // > // Type: expression // Hardness: 50 // // // To test unary and binary operators // # 902 // Arithmetic.-.Correct // > // - - // > // Type: expression // Hardness: 50 // // // To test unary and binary operators // # 903 // Arithmetic.-.Correct // > // { = ; = ; - + ;} // > // Type: expression // Hardness: 50 // // // To test unary and binary operators // # 904 // Arithmetic.+.Correct // > // { = ; = ; + - ;} // > // Type: expression // Hardness: 50 // -------------------------------------------------------------------------- // Templates here are for demonstration purposes // Included at the end so that regular practice does not pick up these templates // How to enter underbraces # 90 Demonstration > 2 + 4 + 1 + 3 > Type: expression Hardness: 50 // How to enter real values # 91 Demonstration > 2.0 + 3.0 > Type: expression Hardness: 50 // How to enter error values # 92 Demonstration > 2 / 0 > Type: expression Hardness: 15 // --------------------------------------------------------------------------