Programa 2
-
Upload
joselyn-aguirre -
Category
Software
-
view
16 -
download
0
Transcript of Programa 2
![Page 1: Programa 2](https://reader036.fdocuments.us/reader036/viewer/2022082812/55b846d1bb61eb12638b4701/html5/thumbnails/1.jpg)
PROGRAMA 2
Package com.example.programa2;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void sumar(View view){
EditText et1=(EditText) findViewById (R.id.num1);
EditText et2=(EditText) findViewById (R.id.num2);
TextView sol=(TextView) findViewById (R.id.res);
![Page 2: Programa 2](https://reader036.fdocuments.us/reader036/viewer/2022082812/55b846d1bb61eb12638b4701/html5/thumbnails/2.jpg)
double n1=Double.parseDouble(et1.getText().toString());
double n2=Double.parseDouble(et2.getText().toString());
double r;
r=n1+n2
sol.setText(String.valueOf("El resultado de"+n1+"+"+n2+" = "+r));
}
}