Simple Calculator in eclipse | Eclipse

Pubblicato il: 28 ottobre 2019
sul canale di: Rayncode
155
2

Join Discord Community:   / discord  

Building a simple calculator app

1) 3 EditText
2) 1 RadioGroup with additional radio button
3) Write Java codes
4) implement OnCheckedChangeListener
5) add Unimplemented Method to MainActivity
6) Write the calculating codes
7) Now Run the Application

EditText et1, et2, et3;
RadioGroup rg;
RadioButton rb0, rb1, rb2, rb3;

et1 = (EditText) findViewById(R.id.editText1);
et2 = (EditText) findViewById(R.id.editText2);
et3 = (EditText) findViewById(R.id.editText3);


rg = (RadioGroup)findViewById(R.id.radioGroup1);


rb0=(RadioButton)findViewById(R.id.radio0);
rb1=(RadioButton)findViewById(R.id.radio1);
rb2=(RadioButton)findViewById(R.id.radio2);
rb3=(RadioButton)findViewById(R.id.radio3);

rg.setOnCheckedChangeListener(this);

float n1, n2, n3 = 0;

n1 = Float.parseFloat(et1.getText().toString());
n2 = Float.parseFloat(et2.getText().toString());

if(checkedId == rb0.getId())
n3 = n1 + n2;
else if(checkedId == rb1.getId())
n3 = n1 - n2;
else if(checkedId == rb2.getId())
n3 = n1 * n2;
else if(checkedId == rb3.getId())
n3 = n1 / n2;

et3.setText(n3 + "");

Source Code: https://github.com/Yaseen549/SimpleCa...
Follow on GitHub: https://github.com/Yaseen549


In questa pagina del sito puoi guardare il video online Simple Calculator in eclipse | Eclipse della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Rayncode 28 ottobre 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 155 volte e gli è piaciuto 2 spettatori. Buona visione!