Professional Documents
Culture Documents
EDUCATION
Topic: Calculator
Course:CO6I
Course Code: 22617
1
CERTIFICATE
This is to certify that,
2
WEEKLY PROGRESS REPORT
MICRO PROJECT
Preparation and
2 submission of Abstract
2nd
3 Literature Review
3rd
th
4 4th and 5 Collection of Data
Final submission of
12 16th Micro Project
3
ANEEXURE II
Evaluation Sheet for the Micro Project
Academic Year :2021-2022 Name of the Faculty: Prof. J.S.Chandwade.
Sub: MAD Course Code: CO6I
Semester: VI
Title of the project:
Cos addressed by Micro Project:
A. Interprete feature of Android operating system.
B. Develop rich user Interfaces by using layouts and controls.
C. Use User interface components for android application development.
D. Configure Android environment and development tools.
Major learning outcomes achieved by students by doing the project
(a) Practical outcome:
1. Install & configure Android Studio.
2. Configure android development tools(ADT).
3. Android program to implement layouts.
4. Programs to Async task using SQLite.
(b) Unit outcomes in Cognitive domain:
1. Write / assure / made the Document.
(c) Outcomes in Affective domain:
1. Follows safety practices.
2. Follow Ethics.
3. Practice Good Housekeeping. 4.
Comments/suggestions about team work /leadership/inter-personal
communication (if any)
……………….…………………………………...…………………………...............................
(Signature of Faculty)
4
INDEX
Sr No. Content Page No.
1 ACKNOWLEDGEMENT 6
2 INTRODUCTION 7
3 ABOUT PROJECT 8
4 PROCEDURE 9
6 CODE 11
7 OUTPUT 23
8 CONCLUSION 25
9 REFERENCE 26
5
ACKNOWLEDGEMENT
6
INTRODUCTION
Android is a mobile operating system based on a modified
version of the Linux kernel and other open source software, designed
primarily for touchscreen mobile devices such as smartphones and
tablets. Android is developed by a consortium of developers known as
the Open Handset Alliance and commercially sponsored by Google. It
was unveiled in November 2007, with the first commercial Android
device, the HTC Dream, being launched in September 2008.
Android Studio is the official[7] integrated development
environment (IDE) for Google's Android operating system, built on
JetBrains' IntelliJ IDEA software and designed specifically for Android
development.[8] It is available for download on Windows, macOS and
Linux based operating systems or as a subscription-based service in
2020.[9][10] It is a replacement for the Eclipse Android Development
Tools (E-ADT) as the primary IDE for native Android application
development.
Android Studio was announced on May 16, 2013, at the Google
I/O conference. It was in early access preview stage starting from version
0.1 in May 2013, then entered beta stage starting from version 0.8 which
was released in June 2014.[11] The first stable build was released in
December 2014, starting from version 1.0.[12]
Gradle is a build automation tool for multi-language software
development. It controls the development process in the tasks of
compilation and packaging to testing, deployment, and publishing.
Supported languages include Java (as well as Kotlin, Groovy, Scala),
C/C++, and JavaScript.[2] It also collects statistical data about the usage
of software libraries around the globe.
7
ABOUT PROJECT
This whole project has only one concept, that to do calculations. You can
perform calculations as in the simple calculator. This whole project is designed
using Android Studio. The project uses Java programming language for field
validations. Gradle’s and wrappers are used for assigning the SDK’s and other
runtimes platforms. This project also can be implemented in different gadgets
like mobile phones. The whole project has a simple-looking UI design.
In order to run the project, first, install Android Studio. Then import the project
from the studio’s homepage. Your project setup will automatically start. All the
Gradle build files will automatically install inside your project root directory.
Run the project and set up your virtual device and run the emulator. The project
will start and there you can add your task and to-do lists.
To develop this simple calculator app the requirements and prerequisites are as
follows:
1. Java: First of all you need to have the knowledge of Java Programming. Java
programming plays a very important role as we will develop the app code in
Java
8
PROCEDURE
2. Now, we’ll see what’s there in the code to understand it better. So to create
the interface we’ve added the number button and the operators for the
calculator. This will be for the users to interact with our calculator. We’ve
arranged them horizontally in four layers. This will be present in the
main_activity.xml file.
3. Also, there are the following things that we have added in the drawable that
are as follows:
1. The description of the buttons that we use. You can find that code in Res
> drawable > Buttons.xml
2. We have added the description of the operator buttons. You can find that
code in Res > drawable > Operator.xml
3. We also described the selector in drawable, it will show the effect as soon
as we select the buttons. You can find that code in Res > drawable >
Selector.xml
4. And then finally we had written the code for the actual processing of the
calculator. For this, the code is written in the MainActivity.java file.
5. So, once we are ready with code we will run the calculator.
9
Advantages and Disadvantages
Even though calculators can do the basic operations instantly, students should not
use it all the time. When a student is always dependent on a calculator for solving
problems of addition, subtraction, multiplication and division, it may make them
incapable of solving these basic operations manually. This may cause them real
trouble during their tests and even at the later stages of their life where they will
need these skills to solve complex problems.
The availability of graphic calculators has made it easier for students to cheat
during their tests. Besides letting you perform basic mathematical operations,
these calculators allow you to store information like notes, formulas etc. This gives
students an opportunity to store unauthorized information to cheat on the test. This
is one of the major disadvantages of a calculator.
10
CODE
XML FILE
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_marginBottom="1pt"
android:layout_height="wrap_content"
android:ems="10"
android:layout_weight="1"
android:background="@color/black"
android:gravity="right|center"
android:textColor="@color/white"
android:textSize="20pt"
android:inputType="textPersonName"
android:text="0" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableRow
11
android:layout_marginBottom="1pt"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnSeven"
android:text="@string/_7"
android:onClick="numberEvent"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:layout_weight="1"
android:textColor="@color/white"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnEight"
android:text="@string/_8"
android:layout_marginRight="1pt"
android:onClick="numberEvent"
android:layout_height="30pt"
android:layout_weight="1"
android:textColor="@color/white"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnNine"
android:text="@string/_9"
android:layout_marginRight="1pt"
android:onClick="numberEvent"
android:layout_height="30pt"
android:layout_weight="1"
12
android:textColor="@color/white"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnDivide"
android:text="@string/div"
android:onClick="operatorEvent"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:textColor="@color/white"
android:layout_weight="1"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableRow
android:layout_marginBottom="1pt"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnFour"
android:text="@string/_4"
android:layout_marginRight="1pt"
android:onClick="numberEvent"
android:textColor="@color/white"
android:layout_height="30pt"
android:layout_weight="1"
13
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnFive"
android:text="@string/_5"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:textColor="@color/white"
android:onClick="numberEvent"
android:layout_weight="1"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnSix"
android:text="@string/_6"
android:layout_marginRight="1pt"
android:onClick="numberEvent"
android:layout_height="30pt"
android:textColor="@color/white"
android:layout_weight="1"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnMultiply"
android:text="@string/multiply"
android:onClick="operatorEvent"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:textColor="@color/white"
android:layout_weight="1"
14
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableRow
android:layout_width="match_parent"
android:layout_marginBottom="1pt"
android:layout_height="match_parent">
<Button
android:id="@+id/btnOne"
android:text="@string/one"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:layout_weight="1"
android:textColor="@color/white"
android:onClick="numberEvent"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnTwo"
android:text="@string/two"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:textColor="@color/white"
android:layout_weight="1"
15
android:onClick="numberEvent"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnThree"
android:text="@string/three"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:layout_weight="1"
android:layout_width="30pt"
android:textColor="@color/white"
android:onClick="numberEvent"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnMinus"
android:text="@string/minus"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:onClick="operatorEvent"
android:textColor="@color/white"
android:layout_weight="1"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableRow
16
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="1pt">
<Button
android:id="@+id/btnAC"
android:text="@string/percent"
android:layout_marginRight="1pt"
android:onClick="percentEvent"
android:layout_height="30pt"
android:layout_weight="1"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnZero"
android:text="@string/zero"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:layout_weight="1"
android:textColor="@color/white"
android:layout_width="30pt"
android:onClick="numberEvent"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnDot"
android:text="."
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:onClick="numberEvent"
android:layout_weight="1"
android:textColor="@color/white"
android:layout_width="30pt"
17
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnPlus"
android:text="@string/plus"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:layout_weight="1"
android:textColor="@color/white"
android:onClick="operatorEvent"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableRow
android:layout_width="match_parent"
android:layout_marginBottom="1pt"
android:layout_height="match_parent">
<Button
android:id="@+id/btnC"
android:text="@string/cancel"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:layout_weight="1"
android:layout_width="30pt"
18
android:onClick="clearEvent"
android:background="@color/purple_200"
></Button>
<Button
android:id="@+id/btnEqual"
android:text="@string/equal"
android:layout_marginRight="1pt"
android:layout_height="30pt"
android:layout_weight="1"
android:onClick="equalEvent"
android:textColor="@color/white"
android:layout_width="30pt"
android:background="@color/purple_200"
></Button>
</TableRow>
</TableLayout>
</LinearLayout>
19
JAVA FILE
package com.example.tutorial;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
edt1 = findViewById(R.id.editText);
}
public void numberEvent(View view) {
if(isNewOperator)
edt1.setText("");
isNewOperator = false;
String number = edt1.getText().toString();
if(view.getId() == R.id.btnOne){
number += "1";
}
else if(view.getId() == R.id.btnTwo){
number += "2";
}
else if(view.getId() == R.id.btnThree){
number += "3";
}
else if(view.getId() == R.id.btnFour){
20
number += "4";
}
else if(view.getId() == R.id.btnFive){
number += "5";
}
else if(view.getId() == R.id.btnSix){
number += "6";
}
else if(view.getId() == R.id.btnSeven){
number += "7";
}
else if(view.getId() == R.id.btnEight){
number += "8";
}
else if(view.getId() == R.id.btnNine){
number += "9";
}
else if(view.getId() == R.id.btnZero){
number += "0";
}
if(operator == "-")
output = Double.parseDouble(initialNumber) -
Double.parseDouble(newNumber);
edt1.setText(output+"");
}
public void clearEvent(View view) {
edt1.setText("0");
isNewOperator = true;
}
public void percentEvent(View view) {
double num = Double.parseDouble(edt1.getText().toString())/100;
edt1.setText(num+"");
isNewOperator = true;
}
}
22
OUTPUT
23
Multiplicatin of 4*2 Division of 10/2
24
CONCLUSION
25
REFERENCE
https://www.javatpoint.com/
https://www.javatpoint.com/android-tutorial
https://www.javatpoint.com/android-what-where-and-why
https://www.android.com/intl/en_in/
https://developer.android.com/studio
https://en.wikipedia.org/wiki/Android
https://projectworlds.in/android-projects-with-source-code/age-
calculator-android-with-source-code/
https://www.geeksforgeeks.org/how-to-build--calculator-in-
android-studio/
https://play.google.com/store/apps/details?id=com.ng_labs.agec
alculator&hl=en_IN&gl=US
26