title: Need help working out the logic in the code: Kotlin
body: <p>When you enter some value in the &quot;product price&quot; field and select one of the packages (after clicking on the calculate button), the amount indicated in the packages themselves should be added, and the result of this should be displayed in the <code>TextView</code>, when you click on the &quot;round&quot; button, the resulting value should be rounded ... I'm lost and don't know how to implement this, I tried and searched for information on all kinds of sites, but there is very little information, maybe knowledgeable people will :(
  <a href="https://i.stack.imgur.com/IETDO.png" rel="nofollow noreferrer">program</a>
  Kotlin  code:</p>
  <pre><code>package com.example.myapplication
  
  import androidx.appcompat.app.AppCompatActivity
  import android.os.Bundle
  import android.view.View
  import android.widget.RadioButton
  import android.widget.TextView
  
  class MainActivity : AppCompatActivity() {
      private lateinit var radioButton: RadioButton
      private lateinit var radioButton2: RadioButton
      private lateinit var radioButton3: RadioButton
      private lateinit var textView: TextView
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          radioButton = findViewById(R.id.radioButton)
          radioButton2 = findViewById(R.id.radioButton2)
          radioButton3 = findViewById(R.id.radioButton3)
          }
       fun SetOnClick(view: View){
  
       }
      }
  </code></pre>
  <p>Xml code :</p>
  <pre><code>&lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;
  tools:context=&quot;.MainActivity&quot;&gt;
  
  &lt;Button
      android:id=&quot;@+id/button&quot;
      android:layout_width=&quot;204dp&quot;
      android:layout_height=&quot;61dp&quot;
      android:layout_marginStart=&quot;149dp&quot;
      android:layout_marginEnd=&quot;168dp&quot;
      android:layout_marginBottom=&quot;228dp&quot;
      android:text=&quot;Рассчитать&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot; /&gt;
  
  &lt;Switch
      android:id=&quot;@+id/switch1&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginStart=&quot;298dp&quot;
      android:layout_marginEnd=&quot;25dp&quot;
      android:layout_marginBottom=&quot;315dp&quot;
      android:minHeight=&quot;48dp&quot;
      android:text=&quot;Округлить&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot; /&gt;
  
  &lt;com.google.android.material.textfield.TextInputLayout
      android:id=&quot;@+id/textInputLayout&quot;
      android:layout_width=&quot;409dp&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginStart=&quot;2dp&quot;
      android:layout_marginTop=&quot;63dp&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;
  
      &lt;com.google.android.material.textfield.TextInputEditText
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:hint=&quot;Цена продукта&quot; /&gt;
  &lt;/com.google.android.material.textfield.TextInputLayout&gt;
  
  &lt;RadioButton
      android:id=&quot;@+id/radioButton&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginStart=&quot;35dp&quot;
      android:layout_marginTop=&quot;83dp&quot;
      android:layout_marginEnd=&quot;188dp&quot;
      android:text=&quot;Начальный пакет (+5%)&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toBottomOf=&quot;@+id/textInputLayout&quot; /&gt;
  
  &lt;RadioButton
      android:id=&quot;@+id/radioButton2&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginStart=&quot;35dp&quot;
      android:layout_marginTop=&quot;15dp&quot;
      android:layout_marginEnd=&quot;165dp&quot;
      android:text=&quot;Продвинутый пакет (+10%)&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toBottomOf=&quot;@+id/radioButton&quot; /&gt;
  
  &lt;RadioButton
      android:id=&quot;@+id/radioButton3&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginStart=&quot;35dp&quot;
      android:layout_marginTop=&quot;6dp&quot;
      android:layout_marginEnd=&quot;196dp&quot;
      android:text=&quot;Элитный пакет (+25%)&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toBottomOf=&quot;@+id/radioButton2&quot; /&gt;
  
  &lt;TextView
      android:id=&quot;@+id/textView&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginStart=&quot;157dp&quot;
      android:layout_marginTop=&quot;68dp&quot;
      android:layout_marginEnd=&quot;196dp&quot;
      android:layout_marginBottom=&quot;141dp&quot;
      android:text=&quot;TextView&quot;
      android:textSize=&quot;60sp&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintHorizontal_bias=&quot;0.395&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toBottomOf=&quot;@+id/button&quot;
      app:layout_constraintVertical_bias=&quot;0.475&quot; /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>