File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 180
180
- [ Rock Paper Scissors!] ( rock-paper-scissors " 5672a98bdbdd995fad00000f ")
181
181
- [ Sentence Smash] ( sentence-smash " 53dc23c68a0c93699800041d ")
182
182
- [ Short Long Short] ( short-long-short " 50654ddff44f800200000007 ")
183
+ - [ simple calculator ] ( simple-calculator " 5810085c533d69f4980001cf ")
183
184
- [ Simple Fun #1 : Seats in Theater] ( simple-fun-number-1-seats-in-theater " 588417e576933b0ec9000045 ")
184
185
- [ Simple multiplication] ( simple-multiplication " 583710ccaa6717322c000105 ")
185
186
- [ Simple validation of a username with regex] ( simple-validation-of-a-username-with-regex " 56a3f08aa9a6cc9b75000023 ")
Original file line number Diff line number Diff line change
1
+ # [ simple calculator ] ( https://www.codewars.com/kata/simple-calculator " https://www.codewars.com/kata/5810085c533d69f4980001cf ")
2
+
3
+ You are required to create a simple calculator that returns the result of addition, subtraction, multiplication or division of two numbers.
4
+
5
+ Your function will accept three arguments:<br >
6
+ The first and second argument should be numbers.<br >
7
+ The third argument should represent a sign indicating the operation to perform on these two numbers.
8
+ ``` if-not:csharp,java
9
+ if the variables are not numbers or the sign does not belong to the list above a message "unknown value" must be returned.
10
+ ```
11
+ ``` if:csharp,java
12
+ If the sign is not a valid sign, throw an IllegalArgumentException (Java) or ArgumentException (C#).
13
+ ```
14
+
15
+ # Example:
16
+
17
+ ~~~ if-not:csharp,java
18
+ ```
19
+ arguments: 1, 2, "+"
20
+ should return 3
21
+
22
+ arguments: 1, 2, "&"
23
+ should return "unknown value"
24
+
25
+ arguments: 1, "k", "*"
26
+ should return "unknown value"
27
+ ```
28
+ ~~~
29
+ ~~~ if:csharp,java
30
+ ```
31
+ arguments: 1, 2, "+"
32
+ should return 3
33
+
34
+ arguments: 1, 2, "&"
35
+ should throw an IllegalArgumentException (Java) or ArgumentException (C#)
36
+ ```
37
+ ~~~
38
+
39
+ Good luck!
You can’t perform that action at this time.
0 commit comments