- 2

Write a program to subtract a float number from an integer number and give result in integer by using local variables

27th Sep 2021, 11:32 AM
Krishna Shaw
4 Réponses
+ 7
Why?
27th Sep 2021, 11:39 AM
Simba
Simba - avatar
0
And where is your code attempt?
27th Sep 2021, 1:34 PM
Lisa
Lisa - avatar
0
Show your attempts
27th Sep 2021, 5:56 PM
Sayyam Jain
Sayyam Jain - avatar
0
I don't know. Could this be a solution ? fun main(args: Array<String>) { val assigment = Subtract() assigment.intValue = 5 assigment.floatValue = 1.3f assigment.printResult() // prints: 3 } public class Subtract () { var intValue:Int = 0 var floatValue:Float = 0.0f protected var result:Int = 0 fun printResult(): Unit { val tmp = (intValue - floatValue) result = tmp.toInt() println(result) } }
27th Sep 2021, 7:49 PM
Coding Cat
Coding Cat - avatar