|
Button button3=findViewById(R.id.division)
|
bet | 3/3 | Sana | 31.12.2021 | Hajmi | 132,08 Kb. | | #237885 |
| Bog'liq 2-laboratoriya ishi miichASHOT 99
Button button3=findViewById(R.id.division);
String text1 = "19";
String text2 = "23";
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text1 = editText.getText().toString();
String text2 = editText1.getText().toString();
if (text1.isEmpty()) {
Toast.makeText(MainActivity.this, "Input first number", Toast.LENGTH_SHORT).show();
return;
}
if (text2.isEmpty()) {
Toast.makeText(MainActivity.this, "input second number", Toast.LENGTH_SHORT).show();
return;
}
int number1 = Integer.parseInt(text1);
int number2 = Integer.parseInt(text2);
int result = number1 + number2;
TextView Result = findViewById(R.id.result);
Result.setText(String.valueOf(result));
}
});
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text1 = editText.getText().toString();
String text2 = editText1.getText().toString();
if (text1.isEmpty()) {
Toast.makeText(MainActivity.this, "Input first number", Toast.LENGTH_SHORT).show();
return;
}
if (text2.isEmpty()) {
Toast.makeText(MainActivity.this, "input second number", Toast.LENGTH_SHORT).show();
return;
}
int number1 = Integer.parseInt(text1);
int number2 = Integer.parseInt(text2);
int result = number1 - number2;
TextView Result = findViewById(R.id.result);
Result.setText(String.valueOf(result));
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text1 = editText.getText().toString();
String text2 = editText1.getText().toString();
if (text1.isEmpty()) {
Toast.makeText(MainActivity.this, "Input first number", Toast.LENGTH_SHORT).show();
return;
}
if (text2.isEmpty()) {
Toast.makeText(MainActivity.this, "input second number", Toast.LENGTH_SHORT).show();
return;
}
int number1 = Integer.parseInt(text1);
int number2 = Integer.parseInt(text2);
int result = number1 * number2;
TextView Result = findViewById(R.id.result);
Result.setText(String.valueOf(result));
}
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text1 = editText.getText().toString();
String text2 = editText1.getText().toString();
if (text1.isEmpty()) {
Toast.makeText(MainActivity.this, "Input first number", Toast.LENGTH_SHORT).show();
return;
}
Amirdin, [30.05.21 12:53]
if (text2.isEmpty()) {
Toast.makeText(MainActivity.this, "input second number", Toast.LENGTH_SHORT).show();
return;
}
int number1 = Integer.parseInt(text1);
int number2 = Integer.parseInt(text2);
int result = number1 / number2;
TextView Result = findViewById(R.id.result);
Result.setText(String.valueOf(result));
}
});
}
}
Dasturimizning tayyor ko’rinishi.
Do'stlaringiz bilan baham: |
|
|