title: app crashes on button press if nothing is in TextEdit
body: <p>Im working on a small temperature conversion app with Kotlin where the user enters a the temperature in a TextEdit and presses a button to calculate the conversion then conversion  but when the user does not enter a number in the TextEdit and presses the button to do the conversion the app crashes and restarts</p>
  <p>How can I go about fixing this?</p>
  <pre><code>class f_to_c : AppCompatActivity() {
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.f_to_c)
  
          val actionBar = supportActionBar
  
          val temp = findViewById&lt;EditText&gt;(R.id.temp)
          val calculate = findViewById&lt;Button&gt;(R.id.calculate)
  
          val tempEntered = findViewById&lt;TextView&gt;(R.id.tempEntered)
          val result = findViewById&lt;TextView&gt;(R.id.result)
  
          val msg1 = findViewById&lt;TextView&gt;(R.id.msg1)
          val msg2 = findViewById&lt;TextView&gt;(R.id.msg2)
  
  
          if (actionBar != null) {
              actionBar.title = &quot;Fahrenheit To Celsius&quot;
              actionBar.setDisplayHomeAsUpEnabled(true)
          }
  
      calculate.setOnClickListener {
          var x = (temp.getText().toString()).toString().toDouble()
          if (!x.toString().isNullOrEmpty()) {
              if ((x % 1).equals(0.0)) {
                  tempEntered.text = x.toInt().toString()
                  result.text = ((x-32).toFloat()*5/9).toString()
              } else {
                  tempEntered.text = x.toDouble().toString()
                  result.text = ((x-32).toFloat()*5/9).toString()
              }
              msg1.text = &quot;Fahrenheit Is&quot;
              msg2.text = &quot;Celsius&quot;
          } else {
              Toast.makeText(this, &quot;Pls enter a number to convert&quot;, Toast.LENGTH_SHORT).show()
          }
          }
  
      }
  }
  </code></pre>