I am trying to print the range of numbers into a text file using Scala.
Here is my code:
package test
import java.io._
class Normal {
def function(N:Double,File:String) {
val rangetest = ((-N / 2) to (N / 2))
val pw = new PrintWriter(new File(File))
pw.write(rangetest)
pw.close
}
}
object normal_distribution extends App {
val N = 50000.toDouble
val file = "/home/Desktop/output_normal.txt"
val normal_obj = new Normal
normal_obj.function(N, file)
}
But I am getting an error with line
pw.write(rangetest)
Error message: overloaded method value write with alternatives: (x$1: String)Unit <and> (x$1: Array[Char])Unit
<and> (x$1: Int)Unit cannot be applied to
(Range.Partial[Double,scala.collection.immutable.NumericRange[Double]])
I am not able to print the range of values.