Coding a calculation tool for my android. On of the inputs is distance in Feet and Inches.
I have two inputs (input3 and input4) for feet and inches, respectively. In my calculation I am trying to convert these two inputs to a decimal number to be used in the rest of the equation. Here's the part of my code that does this:
private void doCalculation() {
// Get entered input value
String strValue3 = input3.getText().toString();
String strValue4 = input4.getText().toString();
// Perform a hard-coded calculation
double imperial1 = (Integer.parseInt(strValue3) + (Integer.parseInt(strValue4) / 12));
// Update the UI with the result to test if calc worked
output2.setText("Test: "+ imperial1);
}
My test values are 4 feet, 6 inches. The 4 comes across fine, but the 6 inches defaults to 0 when it is divided by 12. So my result is 4.0 I tried cutting the calculation down to JUST the division operation, and the result was 0.0
What am I doing wrong? (fyi: this is my first time using Java)