How does one code for a choice between two options?
if ((one_spinner.getSelectedItem().toString()
.equals("one"))) {
double one_thing = new Double(one.getText()
.toString());
double two_thing = one_thing * 5;
} else {
double two_thing = new Double(one.getText()
.toString());
double one_thing = two / 5;
}
Assuming you want to refer to
one_thingandtwo_thingafter theifstatement, you need to declare them before theifstatement, so that they’ll still be in scope:Note that this can be simplified in terms of removing redundant code:
Or, given that the relationship between the two is always a factor of 5:
Note that conventionally these names would be
oneThingandtwoThing, by the way.