In this stage, our calculator simply adds two integers numbers from the input, and prints out the result.
Stage implementation: addNumbers.kt
Example:
> 5 8
13
Now, the following modifications are added to our simple program from the previous stage:
-
It reads two numbers in a loop and prints the sum in the standard output, until the user inputs
/exit
. -
If a user enters only a single number, the program prints the same number.
-
If a user enters an empty line, the program ignores it.
-
When the exit command is entered, the program prints "Bye!", and terminates.
Stage implementation: lastingCalculator.kt
Example:
> 17 9
26
> -2 5
3
>
> 7
7
> /exit
Bye!