-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathP19_b.kt
40 lines (34 loc) · 1.09 KB
/
P19_b.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package alpha.dex.dex_five
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
class MainActivity2 : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main2)
val tv = findViewById<TextView>(R.id.textView4)
val i = intent
val b = i.getBundleExtra("info")
val x = b?.getInt("First")
val y = b?.getInt("second")
var res = 0
val op = b?.getString("operation")
Toast.makeText(this, " $x $op $y", Toast.LENGTH_LONG).show()
when (op) {
"+" -> if (x != null && y != null) {
res = x + y
}
"-" -> if (x != null && y != null) {
res = x - y
}
"*" -> if (x != null && y != null) {
res = x * y
}
"/" -> if (x != null && y != null) {
res = x / y
}
}
tv.text = res.toString()
}
}