Hi Everyone,

I have started learning scala and am working on a task and facing some problem:

Following is what I have worked on. But I am not getting a desired output but an error. " class Variables need to be abstract since it has two unimplemented variables"

Need your Help. Thanks in Advance.

trait ArithmeticOperations {

var x :Int

var y: Int

def add

def subtract

def multiply

def divide

}

class Variables (xc:Int, yc:Int) extends ArithmeticOperations {

x= xc

y= yc

def add() = x + y

def subtract() = x - y

def multiply() = x * y

def divide() = x / y

}

object TraitExample extends App{

val input1 = args(0).toInt

val input2 = args(1).toInt

var variable = new Variables(input1, input2)

println(variable.add())

println(variable.subtract())

println(variable.multiply())

println(variable.divide())

}

Output:

Execute the program to print the outputs:

(Traits.scala is a file name)

scala Traits.scala 5 3

Output will be:

8

2

15

1