0% found this document useful (0 votes)
76 views7 pages

Assignment Converter

This document contains code for an Android application that converts Bangladeshi Taka (BDT) to US Dollars and British Pounds. The application has an EditText field for entering an amount in BDT, a button to trigger the conversion, and two TextViews to display the converted amounts. When the button is clicked, the code gets the input BDT amount, converts it to a double, and calculates the equivalent values in USD and GBP using exchange rates. These converted values are then set as text on the respective TextViews.

Uploaded by

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

Assignment Converter

This document contains code for an Android application that converts Bangladeshi Taka (BDT) to US Dollars and British Pounds. The application has an EditText field for entering an amount in BDT, a button to trigger the conversion, and two TextViews to display the converted amounts. When the button is clicked, the code gets the input BDT amount, converts it to a double, and calculates the equivalent values in USD and GBP using exchange rates. These converted values are then set as text on the respective TextViews.

Uploaded by

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

package com.example.androidapps.

myapplication1;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

EditText etfTest ;
Button BtClick;
String text;

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

BtClick=findViewById(R.id.BtClick);
etfTest=findViewById(R.id.etfTest);
BtClick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
text=etfTest.getText().toString();
Toast.makeText(MainActivity.this,text,Toast.LENGTH_SHORT).show();
}
});

activitylayout.xml

<EditText
android:id="@+id/etfTest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="BtClick"
android:textsize="30sp"
android:id="@+id/BtClick"
android:layout_below="@+id/e
Practice class android make by ilias ahmed
Converter

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout 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">

<EditText

android:id="@+id/EtBDT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="TK"
android:inputType="numberDecimal"
android:textSize="30sp"
android:gravity="center"
android:textColor="#FFFF"

/>

<Button
android:id="@+id/BtCon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Convert"
android:textSize="30sp"
android:gravity="center"
android:layout_below="@+id/EtBDT"

/>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf=""

>

<TextView
android:id="@+id/TvUSDV"
android:text="USD"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/TvPoundV"
android:text="pound"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>

Main,java

package com.example.androidapps.converter;

import android.icu.util.EthiopicCalendar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

EditText EtBDT;
String BDT;
Double BDTV;
TextView TvPoundV,TvUSDV;
Button BtCon;
Integer BD;

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

EtBDT=findViewById(R.id.EtBDT);
TvPoundV=findViewById(R.id.TvPoundV);
TvUSDV=findViewById(R.id.TvUSDV);
BtCon=findViewById(R.id.BtCon);

BtCon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

BDT=EtBDT.getText().toString();
BD=Integer.parseInt(BDT);
BDTV=Double.parseDouble(BDT);
// BD*0.12;
TvUSDV.setText(String.valueOf(BD*0.12));
TvPoundV.setText(String.valueOf(BDTV*0.12));

}
});

}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy