- 2
Write a program to subtract a float number from an integer number and give result in integer by using local variables
4 Antworten
+ 7
Why?
0
And where is your code attempt?
0
Show your attempts
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)
}
}