• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.
I know it's simple but I am probably over complicating this :D
I want to make a calculator with 3 fields required to get the result.
Example:
Field 1: (2)
Field 2: (4)
Field 3: (2)
Result: 4

Explanation:
Calculator takes what ever is entered in Field 1 AND multiplies it with Field 2, Example: (2*4=8)
Than the calculator takes the RESULT of Field 1 and Field 2 AND divides it with what ever is inserted in Field 3, Example: (8/2=4)
In short: 2*4=8/2=4.
Your help would be much appreciated.
So far I have this and I only have the first 2 fields working:

public class MainActivity extends AppCompatActivity {
private EditText etn1;
private EditText etn2;
private TextView appview;

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etn1 = (EditText) findViewById(R.id.etn1);
etn2 = (EditText) findViewById(R.id.etn2);
appview = (TextView) findViewById(R.id.appview);

}

public void btnshoot(View view) {
int n1 = Integer.parseInt(etn1.getText().toString());
int n2 = Integer.parseInt(etn2.getText().toString());
int sum = n1 * n2;
appview.setText(String.valueOf(sum));
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones