def plus(c1: Int, c2: Int): Int = {
return c1 + c2
}
def minus(c1: Int, c2: Int): Int = {
return c1 - c2
}
def div(c1: Int, c2: Int): Double = {
return c1 / c2
}
def mult(c1: Int, c2: Int): Double = {
return c1 * c2;
}
def main(args: Array[String]): Unit = {
println("Number 1: ")
val in = readInt()
println("Number 2: ")
val in2 = readInt()
println("1-Plus, 2-Minus, 3-Division, 4-Multiplication\n")
val des = readInt()
val result = des match {
case '1' => plus(in, in2)
case '2' => minus(in, in2)
case '3' => div(in, in2)
case '4' => mult(in, in2)
}
println("Result: " + result)
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.