Practical 2 : Android Program for Arithmetic Operations - IndianTechnoEra
Latest update Android YouTube

Practical 2 : Android Program for Arithmetic Operations

Aim:

Write a program to perform basic arithmetic operations using a calculator.


Process

In this practical, it has been performed the basic arithmetic operation like addition, subtraction, multiplication and division.



UI Design (input field & buttons)

For this it has taken two text input fields( which is also known as edit text) by which the user can put their number to calculate.

Drag four different buttons to perform the addition, subtraction, multiplication and division in the activity_main.xml file.

Project ( MySeconApp) >> app >> res >> layout >> activity_main.xml


Define element appear text

For button it has been defined the text in the String.xml file

Project ( MySeconApp)  >> app >> res >> values >> string.xml


Define the methods the code

Then define the methods and code expression within the MainActivity.java

Project ( MySeconApp)  >> app >> java >> com.example.mysecondapp >> MainActivity.


Code:


MainActivity.java


strings.xml


activity_main.xml

 


Output:

 



Post a Comment

Feel free to ask your query...
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.