St. John College of Engineering and Management, Palghar

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Aldel Education Trust’s

St. John College of Engineering and Management, Palghar


(A Christian Religious Minority Institution)
Approved by AICTE and DTE, Affiliated to University of Mumbai/MSBTE
St. John Technical Campus, Vevoor, Manor Road, Palghar (E), Dist. Palghar, Maharashtra-401404
Department of Computer Engineering
NAAC Accredited with Grade ‘A’
Name: Amit Ashish Pal

T.E. A2 batch

Roll no: 36

Experiment No:10 
Aim: Implementation of income tax/loan EMI calculator and deploy the same on real 
devices. 
Theory: 
1) ANDROID(OS): Android is a mobile operating system (OS) based on the
Linux kernel and  currently developed by Google. With a user interface based
on direct manipulation, Android is  designed primarily for touch-screen mobile
devices such as smart-phones and tablet computers,  with specialized user
interfaces for televisions (Android TV), cars (Android Auto), and wrist 
watches (Android Wear). 
2) ANDROID STUDIO: Android Studio is an integrated development
environment (IDE) for  developing on the Android platform. It was announced
on May 16, 2013 at the Google I/O  conference by Google's Product Manager,
Ellie Powers. Android Studio is freely available  under the Apache License 2.0 
3) ANDROID STUDIO: Android Studio is an integrated development
environment (IDE) for  developing on the Android platform. It was announced
on May 16, 2013 at the Google I/O  conference by Google's Product Manager,
Ellie Powers. Android Studio is freely available  under the Apache License 2.0 
Code: 
1) MainActivity.java 
package com.smit.calculator; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView; 
public class MainActivity extends AppCompatActivity { 
static int op1 = 0; 
static int op2 = 0; 
static String op; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
Aldel Education Trust’s
St. John College of Engineering and Management, Palghar
(A Christian Religious Minority Institution)
Approved by AICTE and DTE, Affiliated to University of Mumbai/MSBTE
St. John Technical Campus, Vevoor, Manor Road, Palghar (E), Dist. Palghar, Maharashtra-401404
Department of Computer Engineering
NAAC Accredited with Grade ‘A’
super.onCreate(savedInstanceState); 
setContentView(R.layout.activity_main); 

void setdisplay(View v){ 
Button b = (Button)v; 
TextView disp = (TextView) findViewById(R.id.disp); 
CharSequence s = (String) disp.getText() + (String) b.getText(); 
disp.setText(s); 

void operation(View v){ 
Button b = (Button) v; 
TextView disp = (TextView) findViewById(R.id.disp); 
op = (String) b.getText(); 
op1 = Integer.parseInt((String) disp.getText()); 
disp.setText(""); 

void result(View v){ 
Button b = (Button) v; 
TextView disp = (TextView) findViewById(R.id.disp); 
int res; 
op2 = Integer.parseInt((String) disp.getText());
if(op.equals("+")){ 
res = op1+op2; 
}else if(op.equals("-")){ 
res = op1-op2; 
}else{ 
res = 0; 

disp.setText(res + ""); 

void clear(View v){ 
TextView disp = (TextView) findViewById(R.id.disp); 
disp.setText(""); 


Aldel Education Trust’s
St. John College of Engineering and Management, Palghar
(A Christian Religious Minority Institution)
Approved by AICTE and DTE, Affiliated to University of Mumbai/MSBTE
St. John Technical Campus, Vevoor, Manor Road, Palghar (E), Dist. Palghar, Maharashtra-401404
Department of Computer Engineering
NAAC Accredited with Grade ‘A’
2) AndroidManifest.xml 
<?xml version="1.0" encoding="utf-8"?> 
<manifest
xmlns:android="http://schemas.android.com/apk/res/androi
d" package="com.smit.calculator"> 
<application 
android:allowBackup="true" 
android:icon="@mipmap/ic_launcher" 
android:label="@string/app_name" 
android:supportsRtl="true" 
android:theme="@style/AppTheme"> 
<activity android:name=".MainActivity"> 
<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<category
android:name="android.intent.category.LAUNCHER"
/> </intent-filter> 
</activity> 
</application> 
</manifest> 
3) Activity_main.xml 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertica
l_margin"
android:paddingLeft="@dimen/activity_horizontal
_margin"
android:paddingRight="@dimen/activity_horizont
al_margin"
android:paddingTop="@dimen/activity_vertical_m
argin" 
tools:context="com.smit.calculator.MainActivity" 
android:orientation="vertical"> 
<LinearLayout 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
Aldel Education Trust’s
St. John College of Engineering and Management, Palghar
(A Christian Religious Minority Institution)
Approved by AICTE and DTE, Affiliated to University of Mumbai/MSBTE
St. John Technical Campus, Vevoor, Manor Road, Palghar (E), Dist. Palghar, Maharashtra-401404
Department of Computer Engineering
NAAC Accredited with Grade ‘A’
android:layout_gravity="center_horizontal"> 
<TextView 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:id="@+id/disp" 
android:layout_alignParentTop="true" 
android:layout_centerHorizontal="true" 
android:textSize="32sp" />
</LinearLayout> 
<LinearLayout 
android:orientation="vertical" 
android:layout_width="match_p
arent"
android:layout_height="wrap_co
ntent"
android:layout_alignParentEnd=
"true"> <LinearLayout 
android:orientation="horizontal" 
android:layout_width="match_
parent"
android:layout_height="wrap_c
ontent"
android:layout_gravity="right">
 
<Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="1" 
android:id="@+id/btn1" 
android:layout_gravity="center_hor
izontal" android:layout_weight="1" 
android:onClick="setdisplay" /> 
<Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="2" 
android:id="@+id/btn2" 
android:layout_weight="1" 
android:onClick="setdisplay" /> 
Aldel Education Trust’s
St. John College of Engineering and Management, Palghar
(A Christian Religious Minority Institution)
Approved by AICTE and DTE, Affiliated to University of Mumbai/MSBTE
St. John Technical Campus, Vevoor, Manor Road, Palghar (E), Dist. Palghar, Maharashtra-401404
Department of Computer Engineering
NAAC Accredited with Grade ‘A’
<Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="3" 
android:id="@+id/btn3" 
android:layout_weight="1" 
android:onClick="setdisplay" /> 
</LinearLayout> 
<LinearLayout 
android:orientation="horizontal" 
android:layout_width="match_pa
rent"
android:layout_height="wrap_co
ntent"> <Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="4" 
android:id="@+id/btn4" 
android:layout_weight="1" 
android:onClick="setdisplay" /> 
<Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="5" 
android:id="@+id/btn5" 
<Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="0" 
android:id="@+id/btn0" 
android:layout_gravity="center_hor
izontal"
android:onClick="setdisplay" /> 
</LinearLayout>
<LinearLayout 
android:orientation="horizontal" 
Aldel Education Trust’s
St. John College of Engineering and Management, Palghar
(A Christian Religious Minority Institution)
Approved by AICTE and DTE, Affiliated to University of Mumbai/MSBTE
St. John Technical Campus, Vevoor, Manor Road, Palghar (E), Dist. Palghar, Maharashtra-401404
Department of Computer Engineering
NAAC Accredited with Grade ‘A’
android:layout_width="match_parent
"
android:layout_height="wrap_conten
t"
android:layout_gravity="center_hori
zontal"> <Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="+" 
android:id="@+id/btnadd" 
android:layout_weight="1" 
android:onClick="operation" /> 
<Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="-" 
android:id="@+id/btnsub" 
android:layout_weight="1" 
android:onClick="operation" /> 
</LinearLayout> 
<LinearLayout 
android:orientation="horizontal" 
android:layout_width="match_pa
rent"
android:layout_height="match_p
arent"> <Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="=" 
android:id="@+id/btnresult" 
android:layout_gravity="center_hor
izontal" android:onClick="result 
android:layout_weight="1" /> 
<Button 
android:layout_width="wrap_co
ntent"
android:layout_height="wrap_c
ontent" android:text="Clear" 
Aldel Education Trust’s
St. John College of Engineering and Management, Palghar
(A Christian Religious Minority Institution)
Approved by AICTE and DTE, Affiliated to University of Mumbai/MSBTE
St. John Technical Campus, Vevoor, Manor Road, Palghar (E), Dist. Palghar, Maharashtra-401404
Department of Computer Engineering
NAAC Accredited with Grade ‘A’
android:id="@+id/btnclear" 
android:layout_gravity="right" 
android:layout_weight="1" 
android:onClick="clear" /> 
</LinearLayout> 
</LinearLayout> 
</LinearLayout>

Output: 

Conclusion: Thus, we have successfully deployed Calculator.

You might also like