-3

I have just started learning scala .I want to print $ using String Interpolation

def main(args:Array[String]){
println("Enter the string")
val inputString:String=readLine()
val inputAsDouble:Double=inputString.toDouble
printf(f" You owe '${inputAsDouble}%.1f3 ")
}

Input is 2.7255 I get output as .You owe 2.73 while i want it as You owe $2.73 any pointers will be of a great help

Amit_Hora
  • 716
  • 1
  • 8
  • 27

1 Answers1

1

Just double it

printf(f" You owe $$${inputAsDouble}%.1f3 ")

Result:

16/06/02 10:16:04: You owe $2,73
SCouto
  • 7,808
  • 5
  • 32
  • 49