Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Introduction
Nowadays, many basic calculator app has been developed to ease user to
calculate something that involving numbers that can take anywhere and use
anytime..Before the basic calculator app has been create,user using the electronic
calculator which is a small portable electronic device used to perform both basic
operations of arithmetic and complex mathematical.But regarding of developing the
basic calculatorapp,theseinventionarenotonlyforthecalculationpurposejustlikethe
the electronic calculator device but this basic calculator app are together in the user
handphone with other app that user can using just touch the screen without only
bringingtheelectroniccalculatordeviceforallthetime.
The
BasicCalculator app (Figure 1.0) calculates and displays the calculations
between the two numbers that the user entered. As the user enters each digit of a
number by touching the
numeric keypad
, they will need to click one of the arithmetic
operationsthatareprovidedoneoftheinterfacestogetthetotaloftheircalculations.
Android Studio software isbeingused todevelopthisapplication.Wehaveused
IceCreamSandwich4.0andSDK15.
SOURCECODE:
MainActivity.java
package
leya.example.org.basiccalculator
import
android.support.v7.app.AppCompatActivity
import
android.os.Bundle
import
android.view.Menu
import
android.view.MenuItem
import
android.view.View
import
android.widget.EditText
import
android.widget.Toast
publicclass
MainActivity
extends
AppCompatActivity{
private
EditText
num1
,
num2
@Override
protectedvoid
onCreate(BundlesavedInstanceState){
super
.onCreate(savedInstanceState)
setContentView(R.layout.
activity_main
)
num1
=(EditText)findViewById(R.id.
editText
)
num2
=(EditText)findViewById(R.id.
editText2
)
@Override
publicboolean
onCreateOptionsMenu(Menumenu){
//Inflatethemenuthisaddsitemstotheactionbar
ifitispresent.
getMenuInflater().inflate(R.menu.
menu_main
,menu)
returntrue
@Override
publicboolean
onOptionsItemSelected(MenuItemitem){
//Handleactionbaritemclickshere.Theactionbar
will
//automaticallyhandleclicksontheHome/Upbutton,so
long
//asyouspecifyaparentactivityin
AndroidManifest.xml.
int
id=item.getItemId()
//noinspectionSimplifiableIfStatement
if
(id==R.id.
action_settings
){
returntrue
returnsuper
.onOptionsItemSelected(item)
}
publicvoid
sumar(Viewv){
int
n1=Integer.
parseInt
(
num1
.getText().toString())
int
n2=Integer.
parseInt
(
num2
.getText().toString())
int
total=n1+n2
mostrar(total)
}
publicvoid
restar(Viewv){
int
n1=Integer.
parseInt
(
num1
.getText().toString())
int
n2=Integer.
parseInt
(
num2
.getText().toString())
int
total=n1n2
mostrar(total)
}
publicvoid
multiplicar(Viewv){
int
n1=Integer.
parseInt
(
num1
.getText().toString())
int
n2=Integer.
parseInt
(
num2
.getText().toString())
int
total=n1*n2
mostrar(total)
}
publicvoid
dividir(Viewv){
int
n1=Integer.
parseInt
(
num1
.getText().toString())
int
n2=Integer.
parseInt
(
num2
.getText().toString())
int
total=
0
if
(n2<=
0
){
total=
0
}
else
{
total=n1/n2
}
mostrar(total)
}
privatevoid
mostrar(
int
total){
Toast.
makeText
(MainActivity.
this
,
"Total="
+total,
Toast.
LENGTH_LONG
).show()
}
}
activity_main.xml
<
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
:orientation=
"vertical"
tools
:context=
".MainActivity"
>
<
LinearLayout
android
:orientation=
"horizontal"
android
:layout_width=
"match_parent"
android
:layout_height=
"wrap_content"
>
<
TextView
android
:layout_width=
"wrap_content"
android
:layout_height=
"wrap_content"
android
:text=
"@string/number1"
android
:id=
"@+id/textView"
/>
<
EditText
android
:layout_width=
"fill_parent"
android
:layout_height=
"wrap_content"
android
:inputType=
"number"
android
:ems=
"10"
android
:id=
"@+id/editText"
/>
</
LinearLayout
>
<
LinearLayout
android
:orientation=
"horizontal"
android
:layout_width=
"match_parent"
android
:layout_height=
"wrap_content"
>
<
TextView
android
:layout_width=
"wrap_content"
android
:layout_height=
"wrap_content"
android
:text=
"@string/number2"
android
:id=
"@+id/textView2"
/>
<
EditText
android
:layout_width=
"fill_parent"
android
:layout_height=
"wrap_content"
android
:inputType=
"number"
android
:ems=
"10"
android
:id=
"@+id/editText2"
/>
</
LinearLayout
>
<
LinearLayout
android
:orientation=
"horizontal"
android
:layout_width=
"match_parent"
android
:layout_height=
"wrap_content"
>
<
Button
android
:layout_width=
"wrap_content"
android
:layout_height=
"wrap_content"
android
:text=
"@string/btnSumar"
android
:id=
"@+id/button"
android
:onClick=
"sumar"
android
:background=
"#ff789a"
/>
<
Button
android
:layout_width=
"wrap_content"
android
:layout_height=
"wrap_content"
android
:text=
"@string/btnRestar"
android
:id=
"@+id/button2"
android
:onClick=
"restar"
android
:background=
"#ffb9dd"
/>
<
Button
android
:layout_width=
"wrap_content"
android
:layout_height=
"wrap_content"
android
:text=
"@string/btnMultiplicar"
android
:id=
"@+id/button3"
android
:onClick=
"multiplicar"
android
:background=
"#FFFF789A"
/>
<
Button
android
:layout_width=
"wrap_content"
android
:layout_height=
"wrap_content"
android
:text=
"@string/btnDividir"
android
:id=
"@+id/button4"
android
:onClick=
"dividir"
android
:background=
"#FFFFB9DD"
/>
</
LinearLayout
>
</
LinearLayout
>
AndroidManifest.xml
<?
xmlversion=
"1.0"
encoding=
"utf8"
?>
<
manifest
xmlns:
android
=
"http://schemas.android.com/apk/res/android"
package=
"leya.example.org.basiccalculator"
>
<
usessdk
android
:minSdkVersion=
"15"
android
:targetSdkVersion=
"15"
/>
<
application
android
:allowBackup=
"true"
android
:icon=
"@mipmap/ic_launcher"
android
:label=
"@string/app_name"
android
:theme=
"@style/AppTheme"
>
<
activity
android
:name=
".MainActivity"
android
:label=
"@string/app_name"
>
<
intentfilter
>
<
action
android
:name=
"android.intent.action.MAIN"
/>
<
category
android
:name=
"android.intent.category.LAUNCHER"
/>
</
intentfilter
>
</
activity
>
</
application
>
</
manifest
>
strings.xml
<
resources
>
<
string
name=
"app_name"
>BasicCalculator</
string
>
<
string
name=
"action_settings"
>Settings</
string
>
<
string
name=
"number1"
>Number1:</
string
>
<
string
name=
"number2"
>Number2:</
string
>
<
string
name=
"btnSumar"
>+</
string
>
<
string
name=
"btnRestar"
></
string
>
<
string
name=
"btnMultiplicar"
>*</
string
>
<
string
name=
"btnDividir"
>/</
string
>
</
resources
>
OUTPUT:
Interface
Figure1.0:Theabovefigureshowstheinterfaceofthecalculator
Process1:Addition
Figure1.2:Theabovefigureshowstheprocessofaddition
Process2:Subtraction
Figure1.3:Theabovefigureshowstheprocessofsubtraction
Process3:Multiplication
Figure1.4:Theabovefigureshowstheprocessofmultiplication
Next,for the third process,when the user enter the number 15 forthe firstempty
space and the fill the second empty space with number11,afterthat userwillclick on
the addition togetthetotalforbothnumber.Whentheprocesssubtractionissuccessful,
thedialogpopupthetotalofbothnumberis165.
Process4:Division
Figure1.5:Theabovefigureshowstheprocessofdivision
Conclusion
In conclusion, the basic calculator has been created nowadays is for ease the
user to calculate any calculation that involving numbers such as addition,subtraction,
multiplication, and division which is user can user use the calculator with touch
recognition than using the manual calculation which is using paper.Regarding from
that,this calculator are already inourmarketablewhen as we can see almost all touch
screen handphone havethese calculator.These can make usercantakeanywhereand
useeverywhereandanytime.
The benefits this invention can improve our productivity as human being to
successful in lifebecause daybydaywillbecomeout with anotherinventionsothese
will be the first enhancement for the inventor to brainstorm their idea to create a
differentideaforthefuture.