1. OPERACIONES ARITMETICAS
CETIS 109
YAMARY SÁNCHEZ RAMOS
EMILIANO GONZÁLEZ MÉNDEZ
CARLOS SAMUEL GUTIÉRREZ RODRÍGUEZ
JUAN ALBERTO DE JESÚS GARCÍA VÁZQUEZ
4° DM PROGRAMACION
MARGARITA ROMERO ALVARADO
2. PASO 1:
• Primero empezamos un nuevo
Android Aplication Proyect y
ponemos el nombre que
gusten.
3. PASO 2:
Insertamos un relative layout
Después radio group y
automáticamente aparecerán 3
radio button, borramos 1
porque solo ocuparemos 2
después agregamos un botón
que se llame CALCULAR,
después agregamos tres
textview
Se llamaran DAME UN
NUMERO, DAME OTRO
NUMERO y resultado, y por su
puesto 2 textfields debajo de
los 2 primeros textview.
4. PASO 3:
• Debemos ir a Package
Explorer para poder abrir
MainActivity en el cual se
encuentra nuestro código
5. package com.example.programa5;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.RadioButton;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstan
ceState);
setContentView(R.layout.acti
vity_main);
}
@Override
public boolean
onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds
items to the action bar if it is present.
getMenuInflater().inflate(R.m
enu.main, menu);
return true;
}
public void operar(View view) {
EditText
et1=(EditText)findViewById(R.id.et1);
EditText
et2=(EditText)findViewById(R.id.et2);
TextView
tv3=(TextView)findViewById(R.id.tv3);
RadioButton
radio0=(RadioButton)findViewById(R.id.radio0);
RadioButton
radio1=(RadioButton)findViewById(R.id.radio1);
int
nro1=Integer.parseInt(et1.getText().toString());
int
nro2=Integer.parseInt(et2.getText().toString());
if (radio0.isChecked()==true) {
int suma=nro1+nro2;
String resu=String.valueOf(suma);
tv3.setText(resu);
} else
if (radio1.isChecked()==true) {
int resta=nro1-nro2;
String resu=String.valueOf(resta);
tv3.setText(resu);
}
}
}
7. PASO 5:
• Ahora guardamos todos los cambios
para poder hacer el siguiente paso
8. PASO 6:
• Por ultimo corremos el programa yendo
a la carpeta que esta en package
Explorer y le damos Run As y en nuestra
primera opción para poder abrir el
emulador y correr nuestra aplicación
para poder hacer las pruebas y LISTO!!
Terminamos.
9. CONCLUSIÓN:
• Existe un error en la acción del
botón que hay que prestarle
mucha acción porque ese
simple error puede perjudicar
todo el programa y no correrá y
se cerrara automáticamente.
Carlos Samuel Gutiérrez Rodríguez 4DM