title: I'm trying to figure out why my app isn't working
body: <p>Cannot for the life of me figure out what I am doing wrong. When I press my button the app crashes. If someone could help with that problem you'd be amazing. I need to get that to cease so I can test for the functionalities.  My if you see anything else wrong with my code or see a better way of doing please don't hesitate to correct me. Constructive feedback is always welcome.</p>
  
  <p>These are all the functionalities it should have. <a href="https://youtu.be/qAXK2RxIh_s" rel="nofollow noreferrer">https://youtu.be/qAXK2RxIh_s</a></p>
  
  <p>Here's my code:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      RadioGroup radioGroup;
      RadioButton radioButton;
      TextView selected_button;
      TextView problem;
      TextView correct_answer;
      EditText user_answer;
      TextView support;
  
      int counter = 0;
  
      int high = 0;
      int low = 99;
      int count= 0;
      public int randGen(int low, int high) {
          return (int) Math.round(Math.random() * (high - low)) + low;
      }
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          radioGroup = findViewById(R.id.radioGroup);
  
          selected_button = findViewById(R.id.selection);
  
          problem = findViewById(R.id.equation);
  
          user_answer = findViewById(R.id.solution);
  
          correct_answer = findViewById(R.id.answer_check);
  
          support = findViewById(R.id.encouragement);
  
          final Button buttonChecked = findViewById(R.id.button_check);
          Button buttonProblem = findViewById(R.id.button_problem);
  
          buttonProblem.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  //boolean checked = ((RadioButton) view).isChecked();
  
                  //Timer
                  new CountDownTimer(30000,100){
                      public void onTick(long millisUnitilFinished){
                          support.setText(String.valueOf(counter));
                      }
  
                      public void onFinish(){
  
                      }
                  }.start();
  
                  int radioId = radioGroup.getCheckedRadioButtonId();
  
                  radioButton = findViewById(radioId);
  
                  user_answer.setText(" ");
  
                  //Addition method
                  if (radioId == R.id.add){
  
                      int num1;
                      int num2;
                      int sum;
  
                      num1 = randGen(0,99);
                      num2 = randGen(0,99);
  
                      problem.setText(num1 + '+' + num2 + '=');
  
                      sum = num1 + num2;
  
                      correct_answer.setText(sum);
  
                      support.setText(" ");
  
                  }
                  //Subtraction method
                  if (radioId == R.id.sub){
  
                      int num1;
                      int num2;
                      int diff;
  
                      num1 = randGen(0,99);
                      num2 = randGen(0,99);
  
                      problem.setText(num1 + '+' + num2 + '=');
  
                      diff = num1 - num2;
  
                      correct_answer.setText(diff);
  
                      support.setText(" ");
  
  
                  }
                  //Product method
                  if (radioId == R.id.prod){
  
                      int num1;
                      int num2;
                      int product;
  
                      num1 = randGen(0,99);
                      num2 = randGen(0,99);
  
                      problem.setText(num1 + '+' + num2 + '=');
  
                      product = num1 * num2;
  
                      correct_answer.setText(product);
  
                      support.setText(" ");
  
  
                  }
                  //Division Method
                  //Should only give problems whose remainder is zero.
                  if (radioId == R.id.div){
  
                      int num1;
                      int num2;
                      int division;
  
                      num1 = randGen(0,99);
                      num2 = randGen(0,99);
  
                      problem.setText(num1 + '+' + num2 + '=');
  
                      division = num1 / num2;
  
                      correct_answer.setText(division);
  
                      support.setText(" ");
  
                  }
  
              }
          });
  
          buttonChecked.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  //correct answer
                  if(user_answer == (EditText) correct_answer){
                      support.setText("Keep up the good work!");
                      buttonChecked.setEnabled(false);
                  }
                  //incorrect answer number 2
                  else if(count == 1){
                      buttonChecked.setEnabled(false);
                      support.setText("This is the correct answer" + correct_answer + "You suck!");
                      count--;
                  }
                  //incorrect answer number 1
                  else if(user_answer != correct_answer){
                      support.setText("I guess you can try one more time.");
                      count++;
                  }
                  //If no answer is typed but button is pressed.
                  if(user_answer.length()==0){
                      support.setText("ANSWER THE QUESTION!!");
  
                  }
  
  
              }
          });
  
      }
      //Message that lets user know what operation they have selected
      public void checkButton(View v){
          int radioId = radioGroup.getCheckedRadioButtonId();
  
          radioButton = findViewById(radioId);
  
          Toast.makeText(this, "You've selected: " + radioButton.getText(), Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>and here is my xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:text="Pick an Arithmetic Operation"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;RadioGroup
          android:id="@+id/radioGroup"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_marginTop="49dp"
          android:orientation="horizontal"
          android:layout_centerHorizontal="true"&gt;
  
          &lt;RadioButton
              android:id="@+id/add"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="+"
              android:layout_weight="1"
              android:textAlignment="center"/&gt;
  
          &lt;RadioButton
              android:id="@+id/sub"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="-"
              android:textAlignment="center"/&gt;
  
          &lt;RadioButton
              android:id="@+id/prod"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="x"
              android:textAlignment="center"/&gt;
  
          &lt;RadioButton
              android:id="@+id/div"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="/"
              android:textAlignment="center"/&gt;
      &lt;/RadioGroup&gt;
  
      &lt;TextView
          android:id="@+id/selection"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/button_problem"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="-123dp"
          android:text="You've selected: "
          android:textSize="25sp"
          android:visibility="invisible" /&gt;
  
      &lt;Button
          android:id="@+id/button_problem"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentStart="true"
          android:layout_alignParentTop="true"
          android:layout_marginTop="123dp"
          android:text="GIVE ME A PROBLEM"
          tools:layout_editor_absoluteX="135dp"
          tools:layout_editor_absoluteY="32dp" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerInParent="true"
          android:text="Type your answer below"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;Button
          android:id="@+id/button_check"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="142dp"
          android:text="CHECK MY ANSWER"
          tools:layout_editor_absoluteX="202dp"
          tools:layout_editor_absoluteY="37dp" /&gt;
  
      &lt;EditText
          android:id="@+id/solution"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="217dp"
          android:ems="10"
          android:inputType="textPersonName" /&gt;
  
      &lt;TextView
          android:id="@+id/equation"
          android:layout_width="170dp"
          android:layout_height="52dp"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="193dp"
          android:text="TextView"
          android:visibility="invisible" /&gt;
  
      &lt;TextView
          android:id="@+id/answer_check"
          android:layout_width="200dp"
          android:layout_height="65dp"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="28dp"
          android:text="TextView"
          android:visibility="invisible" /&gt;
  
      &lt;TextView
          android:id="@+id/encouragement"
          android:layout_width="156dp"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="108dp"
          android:text="TextView"
          android:visibility="invisible" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>