I am able to run sample code, which I have saved in sample.sc
and the results are displaying on Scala console. But I get an error when running the following program, which I saved as the Timeprogram.scala
script:
/**
* Created by sarathrnair on 3/18/15.
*/
println ( "Enter the seconds" )
val totalSeconds=readInt()
val displaySeconds=totalSeconds%60
val totalMinutes=totalSeconds/60
val displayMinutes=totalMinutes%60
val displayHours=totalMinutes/60
val sec=displaySeconds.toString
val min=displayMinutes.toString
val finalString=displayHours+":"+("0"*(2-min.length))+min+":"+("0"*(2-sec.length))+sec
println (finalString)
The error I get is:
Error running scala console. Module is not specified.
Please help me determine the reason behind this error.
The reason for the error mentioned when selecting "Run Scala Console", i.e. -
Error running scala console. Module is not specified.
is that there is no module specified in the Scala Console Run Configuration. Click on the run configuration dropdown and select "Edit Configurations..." There you can specify a module.
But this is just if you want to open a REPL shell within IntelliJ. If you just want to run the Scala program do it as in the accepted answer and just select "Run" instead of "Run Scala Console".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With