Question: (Scala Programming Beginner Question) I'm currently studying in Scala and have a little question in using the method toInt. For example, I have defined the

(Scala Programming Beginner Question)

I'm currently studying in Scala and have a little question in using the method "toInt".

For example, I have defined the some mutable and immutable variables here

val exchangeRate:Double = 0.88

val dollars:Int = 500

var eurosInt:Int = 0

I'm trying to assign to eurosInt the result of converting dollars to euros using exchangeRate by using method "toInt", so I write like this

eurosInt = dollars * exchangeRate.toInt

but the result is 0, so I'm wondering to know can you use "toInt" in a different way to achieve the desired eurosInt result of 440. Thank you so much.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!