0% found this document useful (0 votes)
50 views8 pages

Lab Exer 3

This document describes Laboratory Exercise #3 for a mobile app development class. It lists Reyes as the leader and 6 other students as members. The exercise involves creating an Android app with XML and Java code to convert an input amount from Philippine Pesos to US Dollars, Australian Dollars, Kuwaiti Dinars, Euros, or Chinese Yuan based on preset exchange rates. The app displays the converted amount in an alert dialog box when the "Convert to Peso" button is clicked.

Uploaded by

xilian.reyes.s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views8 pages

Lab Exer 3

This document describes Laboratory Exercise #3 for a mobile app development class. It lists Reyes as the leader and 6 other students as members. The exercise involves creating an Android app with XML and Java code to convert an input amount from Philippine Pesos to US Dollars, Australian Dollars, Kuwaiti Dinars, Euros, or Chinese Yuan based on preset exchange rates. The app displays the converted amount in an alert dialog box when the "Convert to Peso" button is clicked.

Uploaded by

xilian.reyes.s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

MOBILE APP DEVELOPMENT

LABORATORY EXERCISE #3

LEADER:
REYES, XI LIAN (XML AND JAVA)

MEMBERS:
DALISAY, JASPERONE (JAVA)
GARDE, MARK LEO (JAVA)
HIPOLITO, ROD JOSEPH (JAVA)
JERGIL, CHARLES (XML AND JAVA)
LLOSE, BENEDICK (JAVA)
XML CODE:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:orientation="vertical">

<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:gravity="center"
android:hint="ENTER AMOUNT"
android:inputType="numberDecimal"
android:textSize="30dp" />

<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">

<RadioButton
android:id="@+id/usd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="USD (USA)"/>

<RadioButton
android:id="@+id/aud"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AUD (AUSTRALIAN DOLLAR)"/>

<RadioButton
android:id="@+id/kwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KWD (KUWAIT)"/>

<RadioButton
android:id="@+id/eur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EUR (EURO)"/>

<RadioButton
android:id="@+id/cny"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CNY (CHINA)"/>

</RadioGroup>

<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#DCC222"
android:text="CONVERT TO PESO"
android:textSize="18dp"
app:cornerRadius="0px" />

</LinearLayout>

</LinearLayout>
JAVA CODE:
package com.example.labexerthree;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

EditText editText;
RadioGroup radioGroup;
RadioButton usd, aud, kwd, eur, cny;
Button button;
AlertDialog.Builder builder;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initialize();
regListeners();
}

public void initialize(){


editText = findViewById(R.id.editText);
radioGroup = findViewById(R.id.radioGroup);
usd = findViewById(R.id.usd);
aud = findViewById(R.id.aud);
kwd = findViewById(R.id.kwd);
eur = findViewById(R.id.eur);
cny = findViewById(R.id.cny);
button = findViewById(R.id.button);
builder = new AlertDialog.Builder(this);
}

private void regListeners(){


button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int id = radioGroup.getCheckedRadioButtonId();
Button selectedButton = (Button) findViewById(id);

if (selectedButton.getId() == R.id.usd){
String getInput = editText.getText().toString();
if(!getInput.equals("")) {
float peso = Float.parseFloat(getInput);
float usdRate = 56.75F;
float convertedToUSD = peso * usdRate;

builder.setTitle("CONVERT USD TO PESO")


.setMessage("Converted Amount: "+convertedToUSD)
.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface,
int i) {
editText.setText("");
editText.setHint("ENTER AMOUNT");
}
})
.show();

}
else{
Toast.makeText(MainActivity.this,"Input Amount First",
Toast.LENGTH_SHORT).show();
}
}

else if (selectedButton.getId() == R.id.aud){


String getInput = editText.getText().toString();
if(!getInput.equals("")) {
float peso = Float.parseFloat(getInput);
float audRate = 35.77F;
float convertedToAUD = peso * audRate;

builder.setTitle("CONVERT AUD TO PESO")


.setMessage("Converted Amount: "+convertedToAUD)
.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface
dialogInterface, int i) {
editText.setText("");
editText.setHint("ENTER AMOUNT");
}
})
.show();

}
else{
Toast.makeText(MainActivity.this,"Input Amount First",
Toast.LENGTH_SHORT).show();
}
}

else if (selectedButton.getId() == R.id.kwd){


String getInput = editText.getText().toString();
if(!getInput.equals("")) {
float peso = Float.parseFloat(getInput);
float kwdRate = 183.44F;
float convertedToKWD = peso * kwdRate;
builder.setTitle("CONVERT KWD TO PESO")
.setMessage("Converted Amount: "+convertedToKWD)
.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface
dialogInterface, int i) {
editText.setText("");
editText.setHint("ENTER AMOUNT");
}
})
.show();

}
else{
Toast.makeText(MainActivity.this,"Input Amount First",
Toast.LENGTH_SHORT).show();
}

else if (selectedButton.getId() == R.id.eur) {


String getInput = editText.getText().toString();
if(!getInput.equals("")) {
float peso = Float.parseFloat(getInput);
float eurRate = 59.34F;
float convertedToEUR = peso * eurRate;

builder.setTitle("CONVERT EURO TO PESO")


.setMessage("Converted Amount: "+convertedToEUR)
.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface
dialogInterface, int i) {
editText.setText("");
editText.setHint("ENTER AMOUNT");
}
})
.show();

}
else{
Toast.makeText(MainActivity.this,"Input Amount First",
Toast.LENGTH_SHORT).show();
}
}

else if (selectedButton.getId() == R.id.cny){


String getInput = editText.getText().toString();
if(!getInput.equals("")) {
float peso = Float.parseFloat(getInput);
float cnyRate = 7.77F;
float convertedToCNY = peso * cnyRate;
builder.setTitle("CONVERT CNY TO PESO")
.setMessage("Converted Amount: "+convertedToCNY)
.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface
dialogInterface, int i) {
editText.setText("");
editText.setHint("ENTER AMOUNT");
}
})
.show();

}
else{
Toast.makeText(MainActivity.this,"Input Amount First",
Toast.LENGTH_SHORT).show();
}

}
});

}
SCREENSHOT WITH MEMBERS:

You might also like