alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix

# Akka/Scala example source code file (CalculatorActor.scala)

This example Akka source code file (CalculatorActor.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Akka and Scala source code examples by using tags.

All credit for the original source code belongs to akka.io; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

## Akka tags/keywords

actor, add, addresult, akka, calculating, calculatoractor, divide, divisionresult, multiplicationresult, multiply, remote, subtractresult

## The CalculatorActor.scala Akka example source code

```package sample.remote.calculator

import akka.actor.Props
import akka.actor.Actor

class CalculatorActor extends Actor {
println("Calculating %d + %d".format(n1, n2))
sender() ! AddResult(n1, n2, n1 + n2)
case Subtract(n1, n2) =>
println("Calculating %d - %d".format(n1, n2))
sender() ! SubtractResult(n1, n2, n1 - n2)
case Multiply(n1, n2) =>
println("Calculating %d * %d".format(n1, n2))
sender() ! MultiplicationResult(n1, n2, n1 * n2)
case Divide(n1, n2) =>
println("Calculating %.0f / %d".format(n1, n2))
sender() ! DivisionResult(n1, n2, n1 / n2)
}
}

```

## Other Akka source code examples

Here is a short list of links related to this Akka CalculatorActor.scala source code file:

 ... this post is sponsored by my books ... #1 New Release! FP Best Seller