Inspired by a post I saw on social media, your job is to create a miscalculator (aka "wrongulator"): a calculator which always outputs the wrong answer!
Write a program that inputs a string or text file of individual expressions such as:
5*7, 21/3, or 11-3
And returns a wrong answer for the expression (in this case, anything except for 35, 7, and 8 in that order). To simplify the task a little, the input must only be one operator at a time.
The program will emulate a basic calculator, so it should be able to handle addition, subtraction, multiplication and division.
The output must be "reasonably" believable:
5 + 6 = 20 and 5 + 6 = -1 are allowed, but 5 + 6 = 3.18888, 2453139, or -258 are all not.
The outputs must not be easily predictable (eg, simply adding one to the correct result every time), and cannot use any random number functionality your language has. (But can use the built-in functions for square roots etc.) Otherwise the method of producing the wrong answer is up to you.
Consistency is a major plus, so that the same expression is liable to always output the same wrong answer.
The output can either be as a single number or as an equation.
Test Cases and Examples
For example, I might have the following program:
If the operation is addition or subtraction
a +/- b, it adds or subtracts
ceiling(b/6)and multiplies that by 6. If either number is divisible by 6, then we compute
6*(floor(x/5.9) +/- ceil(x/5.9)):
`5 + 9 "=" 12` (real answer is 14) `49 + 36 "=" 90` (real answer is 85). Here 36 is a multiple of 6, so we use the second formula. `21 - 11 "=" 12` (real answer is 10) `4 - 26 "=" -30` (real answer is -22)
If the operation is multiplication,
a*b, it computes
(a-0.3)*(b-0.4)and rounds down, then adds
ceil((a + b)/2)for good measure.
`5*9 "=" 47` (real is 45) `11*(-23) "=" -256` (real is -253)
If the operation is division,
a/b, it simply computes
abs((a-0.3)/(b-0.4)), then tacks on the sign of the original expression (so that if 0 < a < 0.3, for example, the expression won't change sign):
`(-12/14) "=" -0.904...` (real is -0.857...) `183/11 "=" 17.236...` (real is 16.636...)
This is a popularity-contest, so the most popular/creative answer wins.