Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions