Android Currency Converter Project Using Java
In this project, we will be making a currency convertor that converts pounds to dollars.
An android application used to convert pounds to dollars and display it using toast message.
Open Android Studio, create a new project, and name it. The language used is Java.
The minimum SDK used is - API 21
Creating an Android Project
-1625843325-751.png)
Creating the layout of our Application
Now we will be creating the layout for our application.
We will download the background image for the layout and move it to our drawable folder and use it.
We have used text view and edit Text in this layout along with the constraint layout.
The "convert" button converts pounds to the dollar and the result is displayed in a toast message as shown in the image below.
-1625843864-751.png)
Coding in MainActivity.java
The MainActivity.java code is pretty simple for this project.
-1625843612-751.png)
We'll take our input number in double and convert it using the formulae -
Double amountindollarsDouble = amountinpoundsDouble * 1.24;
Now in order to print the result using toast message, we will convert it to string and then print it using -
Toast.makeText(this, "$"+amountString,Toast.LENGTH_LONG).show();
Note - You can convert any desired currency, just replace the formulae with the desired one.
After completing the code, run your application in your emulator.
Project Files
| .. | ||
| This directory is empty. | ||