Hi. I have this bit of code where I'm trying to save the results of a calculation to disk but it says that the variable (txt) cannot be resolved.
Any ideas!
private void handleEquals(int newOperator) {
if (hasChanged) {
switch (operator) {
case 1:
num = num + Double.parseDouble(txtCalc.getText().toString());
break;
case 2:
num = num - Double.parseDouble(txtCalc.getText().toString());
break;
case 3:
num = num * Double.parseDouble(txtCalc.getText().toString());
break;
case 4:
num = num / Double.parseDouble(txtCalc.getText().toString());
break;
}
String txt = Double.toString(num);
txtCalc.setText(txt);
txtCalc.setSelection(txt.length());
readyToClear = true;
hasChanged = false;
}
FileOutputStream fOut = openFileOutput("samplefile.txt",MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(txt);
osw.flush();
fOut.close();
osw.close();
operator = newOperator;
}
Any ideas!
private void handleEquals(int newOperator) {
if (hasChanged) {
switch (operator) {
case 1:
num = num + Double.parseDouble(txtCalc.getText().toString());
break;
case 2:
num = num - Double.parseDouble(txtCalc.getText().toString());
break;
case 3:
num = num * Double.parseDouble(txtCalc.getText().toString());
break;
case 4:
num = num / Double.parseDouble(txtCalc.getText().toString());
break;
}
String txt = Double.toString(num);
txtCalc.setText(txt);
txtCalc.setSelection(txt.length());
readyToClear = true;
hasChanged = false;
}
FileOutputStream fOut = openFileOutput("samplefile.txt",MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(txt);
osw.flush();
fOut.close();
osw.close();
operator = newOperator;
}