DFP 6223 MOBILE APPLICATION DEVELOPMENT
--------------------------------------------------------------------------------------------------------------------------------------
WEEK 3
CONVERT CELCIUS TO FARENHEIT
Step 1 File ->New ->Android Application Project
Step 2
Step 3 Letakkan function onClick
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/editText1"
android :onClick="convert"
android:text="Convert to Farenheit" />
Step 4
Letak header
import [Link];
import [Link];
import [Link];
BY: PN FARIHAN ELYANA BT ZAHARI
DFP 6223 MOBILE APPLICATION DEVELOPMENT
--------------------------------------------------------------------------------------------------------------------------------------
Step 5 File *.java
public void convert(View v) {
EditText inputTeks = (EditText) findViewById([Link].editText1);
String teks = [Link]().toString();
float celcius = [Link](teks);
float faren = ((celcius * 9)/5)+32;
TextView label1 = (TextView) findViewById([Link].textView2);
[Link](celcius + " celcius is equal to " + faren + " Farenheit");
CALCULATE BMI
Step 1 Create android application : CalBMI
Step 2
Step 3 File *.xml
< Button
android:onClick="kiraBMI"
<EditText
pada edit text -> tukar kotak color
put ImageView
Step 4
Put image into folder
CalBMI > res > drawable-ldpi
BY: PN FARIHAN ELYANA BT ZAHARI
DFP 6223 MOBILE APPLICATION DEVELOPMENT
--------------------------------------------------------------------------------------------------------------------------------------
Step 5 File *.java
public void kiraBMI(View v){
EditText att_weight = (EditText) findViewById([Link].editText2);
double weight = [Link](att_weight.getText().toString());
EditText att_height = (EditText) findViewById([Link].editText1);
double height = [Link](att_height.getText().toString());
double bmi = weight / (height * height);
ImageView imej = (ImageView) findViewById([Link].imageView1);
String status;
if(bmi <18.5) {
status = "Underweight";
[Link]([Link]);
}
else if (bmi < 25)
{
status = "ok sahaja";
[Link]([Link]);
}
else
{
status = "Gemuk dah tu";
[Link]([Link]);
}
TextView att_status = (TextView) findViewById([Link].textView3);
att_status.setText("your BMI is " + bmi + ". Your are " + status);
BY: PN FARIHAN ELYANA BT ZAHARI