Untitled
unknown
plain_text
2 years ago
2.3 kB
5
Indexable
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val radioGroup = findViewById<RadioGroup>(R.id.radio_group)
val operador1EditText = findViewById<EditText>(R.id.operador1)
val operador2EditText = findViewById<EditText>(R.id.operador2)
val buttonCalcular = findViewById<Button>(R.id.button_calcular)
buttonCalcular.setOnClickListener {
try {
val operador1 = operador1EditText.text.toString().toDouble()
val operador2 = operador2EditText.text.toString().toDouble()
val selectedRadioButtonId = radioGroup.checkedRadioButtonId
val selectedOption = findViewById<RadioButton>(selectedRadioButtonId).text
// your code to perform when the user clicks on the button
Toast.makeText(this@MainActivity, selectedOption, Toast.LENGTH_SHORT).show()
when (selectedOption) {
"Exponente" -> calcularExponente(operador1, operador2)
"Factorial" -> calcularFactorial(operador1, operador2)
"NumeroIntermedio" -> calcularintermedio(operador1, operador2)
"Mayor" -> Mayor(operador1, operador2)
"Secuencia" -> Secuencia(operador1, operador2)
}
}catch (error: Error){
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
}
}
}
fun calcularExponente(op1: Double, op2: Double){
}
fun calcularFactorial(op1: Double, op2: Double){
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
}
fun calcularintermedio(op1: Double, op2: Double){
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
}
fun Mayor(op1: Double, op2: Double){
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
}
fun Secuencia(op1: Double, op2: Double){
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
}
Editor is loading...
Leave a Comment