fun equalsClick(view: View) {
val sec0perandText: String = resultTextView.text.toString()
var sec0perand: Double = 0.0.roundToInt()
if (!TextUtils.isEmpty(sec0perandText)) {
sec0perand = sec0perandText.toDouble()
}
when (operation) {
"+" -> resultTextView.text = (operand + sec0perand).toString()
"-" -> resultTextView.text = (operand - sec0perand).toString()
"*" -> resultTextView.text = (operand * sec0perand).toString()
"/" -> resultTextView.text = (operand / sec0perand).toString()
}
}
Getting output in double is not an option because it gives Integers .0 in the end. I tried adding .roundToInt()
which didn't work, when compiled it gives following error: Type mismatch: inferred type is Int but Double was expected
.