I'm attempting to develop a calculator app that works the way it should, as opposed to the typical ones that ask for the first and second numbers, followed by the operator.
static int initVal = 1;
static int finalVal = 1;
..
..
..
work.screen.setText(work.screen.getText() );
String keyPressed = Integer.toString(initVal);
initVal = Integer.parseInt(keyPressed);
I developed mine to accept user input as it is typed and then process it. My issue is that if I want to execute a division such that either operator is a float/double, how do I set the initial type of the variables and how do I update the type to accept new variables once input differs from the initial type?
If I key in numbers that include a decimal place or my answer has a decimal place, the interface does not type cast correctly. I tried changing everything to Double instead of integer, however when I key in numbers without a decimal place, they are transformed to fractions. confused.
A solution will be greatly appreciated.