In android studio, the variable "output" in my if/else statement shows up as gray(never used) and then on the last line when I try to use it, I get an error saying "cannot resolve symbol output".
Code:
public void calculate(View view) {
EditText userInput = (EditText) findViewById(R.id.user_input);
String numString = userInput.getText().toString();
double num = new Double(numString).doubleValue();
CheckBox ozCheckBox = (CheckBox)findViewById(R.id.oz);
boolean ozInput = ozCheckBox.isChecked();
CheckBox gCheckBox = (CheckBox)findViewById(R.id.g);
boolean gInput = gCheckBox.isChecked();
if(ozInput == true) {
double output = num*28.3495;
} else {
double output = num;
}
TextView textView = (TextView)findViewById( R.id.output_textview );
textView.setText( String.valueOf( output ) );
}