Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
2.3 kB
0
Indexable
Never
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()
    }
Leave a Comment