DFP 6223 MOBILE APPLICATION DEVELOPMENT
--------------------------------------------------------------------------------------------------------------------------------------
WEEK 4
MATH CALCULATION
Step 1
Step 2 Button 1
android:text="another number"
android:onClick="next"
Step 3 Button 2
android:onClick="result"
android:text="Check Result"
Step 4 File *java
public void next(View v) {
EditText clear1 = (EditText) findViewById(R.id.editText1);
clear1.setText("");
Random randomGen = new Random();
int random1 =randomGen.nextInt(100);
int random2 =randomGen.nextInt(100);
jwp = random1 + random2;
TextView num1 = (TextView) findViewById(R.id.textView1);
num1.setText(Integer.toString(random1));
BY: PN FARIHAN ELYANA BT ZAHARI
DFP 6223 MOBILE APPLICATION DEVELOPMENT
--------------------------------------------------------------------------------------------------------------------------------------
TextView num2 = (TextView) findViewById(R.id.textView4);
num2.setText(Integer.toString(random2));
}
public void result(View v){
EditText value1 = (EditText) findViewById(R.id.editText1);
int jwpUser = Integer.parseInt(value1.getText().toString());
TextView display = (TextView) findViewById(R.id.textView5);
if (jwpUser == jwp)
display.setText("CORRECT");
else
display.setText("WRONG");
BY: PN FARIHAN ELYANA BT ZAHARI