I am developing a small app while learning Android.
The app is basically making a series of simple math calculations. A button is calling a function where the calculations take place. Everything was working fine, until I inserted an if/else construct.
Inside this construct, I am using variables created before, making calculation and setting other variables with this
if (TS>Ex) {
Double AE = 0.00;
} else {
Double AE = (Ex-TS);
};
Double TBTAT = (TS-Ex);
Double Exx = 2864.17;
if (TBTAT>Exx) {
Double TAT = (Exx*0.2);
} else {
Double TAT = (TBTAT*0.2);
};
I have two of these if/else structures.
Then everything is collected and sent to a Text
IT_ResultTXT.setText(Double.toString(AE+TAT+TAF));
In normal conditions, AE, TAT, TAF turn out to "cannot be resolved to a variable" in this last line of the code, but if I declare them at the beginning of the function, I have an error of duplicated variables.
I suppose is a very stupid basic Java programming error, but I cannot find a solution to this.