Showing error in Scala


#1

Where I am making the mistake?


#2

@Shantanu_Gupta

You were using totalEven and totalOdd twice if you want the variables to be used multiple times then they must be declared as mutable variables. In simple words, change val to var.

var totalEven=0
var totalOdd=0