Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

CALCULATOR USING ANDROID STUDIO

Project submitted in partial fulfilment of the requirement for the


award of the degree of
Bachelor of Computer Application
In
Computer Science and Engineering
By
Suraj Sharma (171306003)
Saurav Mehto (171306002)
Saurabh Singh Negi (171306006)

Department of computer Science and Engineering


SGT INSTITUTE OF ENGINEERING AND
TECHNOLOGY
GURGAON
Nov 2019
DECLARATION
We Suraj Sharma (171306003), Saurav Mehto (171306002), Saurabh Singh Negi
(171306006) are student of Bachelor of Computer Application hereby declared that
we are fully responsible for the information and results are provided in this project
report titled “CALCULATOR USING ANDROID STUDIO” submitted
Department of Computer Science and Engineering, SGT University, Gurgaon for
the partial fulfillment of the requirement for the award of the degree Bachelor of
Computer Application. We have already take care in all respects to honor the
intellectual property rights and have acknowledged the contribution of others for
using them. We further declare that in case of any violation of intellectual property
rights or copyrights, we as a candidate will be fully responsible for the same. My
supervisor, Head of Department and the institute should not be held for full or
partial violation of copyrights if found at any stage of my degree.

Signature

Suraj Sharma Saurav Mehto Saurabh Singh Negi

171306003 171306002 171306006


CERTIFIACATE

This is certify that the work in the project report titled “CALCULATOR USING

ANDROID STUDIO” by Suraj, Saurav Mehto, Saurabh Negi is a bona fide

record of the project work carried out by her under my supervision and guidance in

partial fulfillment of the requirements for the award of the degree of Bachelor of

Computer Application in the Department of Engineering and Technology, SGT

University Haryana, Gurgaon. Neither this project nor any part of it has been

submitted for any degree or academic award elsewhere.

Signature

Date:-Nov 20th 2019 Ms. Sangeeta Rani

Assistant Professor

Head

Department of Engineering and Technology

SGT University Haryana, Gurgaon


ACKNOWLEDGEMENT

First and the foremost We Would like to thank to my almighty for giving me

courage to a word of thanks to my teacher, friends and other sources that give an

unending support and helped me in numerous way from the first stage of my term

assignment conceived. We would also like to thank my family members for their

whole hearted support and cooperation. We duly acknowledge the contribution of

MS. SANGEETA RANI for their invaluable help .Coding. We would also thanks

to my all team members for their contribution.


CONTENT:-

1. Introduction and Objectives.


2. Calculator?
3. ANALYSIS (DFD).
4. Tools/Platform.
5. Result
6. Coding
7. Conclusion
CALCULATOR USING ANDROID STUDIO

Introduction and Objectives.


Computer Science undergraduates find “formal methods”, i.e. the use of mathematical notations and
methods for supporting the development of computer software and systems, difficult and in particular
they find the part of formal methods that demands reasoning about their programs the most difficult.
The work reported in this paper set out to see what factors affected these difficulties and also to test the
hypothesis that providing so-called calculators would ease the burden that formal reasoning imposes. In
order to gather these data the project team used many different methods: questionnaires, interviews,
test and exam results, logging of system use and monitoring of teacher and student discussion on
electronic bulletinboards. As we shall see, this data gathering exercise allowed us show some statistically
significant results concerning the experience of students prior to enrolling on the courses. It also, equally
valuably, produced much anecdotal evidence about how courses should be run. The plan of this paper is
as follows: in the next section we introduce and discuss the term “calculators”; we then go on to
introduce the main hypothesis of the experimental work of the project and the design of the
experiments that we conducted; next we introduce and discuss two of the calculators used during the
project; following that we present and discuss the results that we have, so far, obtained; finally we
suggest where a followon project might lead and suggest some improvements to our work.

Calculators?
A calculator, for us, is a self-contained, robust, simple to use software device which supports
working in some area analogous to the way the familiar, hand-held, electronic calculator
supports working in arithmetic. The traditional calculator supports the users in arithmetic tasks
by relieving them of the burden of carrying out the arithmetic operations, allowing them to
concentrate on the substance of the problem at hand. The aim of the calculators developed or
borrowed in this project was to support learning to program in Miranda (“Miranda” is a
trademark of Research Software Ltd.) and the understanding and use of the language of first-
order logic. An important design feature of a calculator should be that it can be used without a
great deal of explanation and instruction. A second feature should be that it provides a way for
students to build-up a reliable model of the way in which a calculation takes place. They should
come to understand how it works and what rules it follows. This means that we actually have two
goals for our calculators: they should support the student in the task of building an understanding
of the activities that the calculator helps to carry out; they should support the student in the more
mechanical and book-keeping parts of their tasks, once learned properly, so that the tasks they
can tackle become progressively harder. When we first developed our ideas for this project we
had also hoped that the calculators would be thought so much fun to use that students would use
them spontaneously and perhaps play with them. This turned out to be a very naïve idea on our
behalf - our students were too busy and so oriented towards doing what they must do to choose
to do something viewed as extra work.

ANALYSIS (DFD):-
Tools/Platform:-
Android Studio
Android Studio is the official integrated development environment (IDE) for Google's Android
operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for
Android development. It is available for download on Windows, macOS and Linux based
operating systems. It is a replacement for the Eclipse Android Development Tools (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. The first stable build was released in December
2014, starting from version 1.0.

 Android-specific refactoring and quick fixes


 Lint tools to catch performance, usability, version compatibility and other problems
 ProGuard integration and app-signing capabilities
 Template-based wizards to create common Android designs and components
 A rich layout editor that allows users to drag-and-drop UI components, option to preview
layouts on multiple screen configurations
 Support for building Android Wear apps
 Built-in support for Google Cloud Platform, enabling integration with Firebase Cloud
Messaging (Earlier 'Google Cloud Messaging') and Google App Engine
 Android Virtual Device (Emulator) to run and debug apps in the Android studio.

Android Studio supports all the same programming languages of IntelliJ (and CLion) e.g. Java,
C++, and more with extensions, such as Go; and Android Studio 3.0 or later supports Kotlin and
"all Java 7 language features and a subset of Java 8 language features that vary by platform
version." External projects backport some Java 9 features. While IntelliJ that Android Studio is
built on supports all released Java versions, and Java 12, it's not clear to what level Android
Studio supports Java versions up to Java 12 (the documentation mentions partial Java 8 support).
At least some new language features up to Java 12 are usable in Android.
Result:-
Coding:-

(For Main Activity) (In Java)


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
Button button0, button1, button2, button3, button4, button5, button6,
button7, button8, button9, buttonAdd, buttonSub, buttonDivision,
buttonMul, button10, buttonC, buttonEqual;
EditText crunchifyEditText;
float mValueOne, mValueTwo;
boolean crunchifyAddition, mSubtract, crunchifyMultiplication, crunchifyDivision;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button0 = (Button) findViewById(R.id.button0);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button4 = (Button) findViewById(R.id.button4);
button5 = (Button) findViewById(R.id.button5);
button6 = (Button) findViewById(R.id.button6);
button7 = (Button) findViewById(R.id.button7);
button8 = (Button) findViewById(R.id.button8);
button9 = (Button) findViewById(R.id.button9);
button10 = (Button) findViewById(R.id.button10);
buttonAdd = (Button) findViewById(R.id.buttonadd);
buttonSub = (Button) findViewById(R.id.buttonsub);
buttonMul = (Button) findViewById(R.id.buttonmul);
buttonDivision = (Button) findViewById(R.id.buttondiv);
buttonC = (Button) findViewById(R.id.buttonC);
buttonEqual = (Button) findViewById(R.id.buttoneql);
crunchifyEditText = (EditText) findViewById(R.id.edt1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + "1");}});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + "2");}});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + "3");}});
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + "4");}});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + "5");}});
button6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {=
crunchifyEditText.setText(crunchifyEditText.getText() + "6");}});
button7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + "7");});
button8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + "8");}});
button9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + "9");}});
button0.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + "0");}});
buttonAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (crunchifyEditText == null) {
crunchifyEditText.setText("");
} else {
mValueOne = Float.parseFloat(crunchifyEditText.getText() + "");
crunchifyAddition = true;
crunchifyEditText.setText(null);}}});
buttonSub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mValueOne = Float.parseFloat(crunchifyEditText.getText() + "");
mSubtract = true;
crunchifyEditText.setText(null);}});
buttonMul.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mValueOne = Float.parseFloat(crunchifyEditText.getText() + "");
crunchifyMultiplication = true;
crunchifyEditText.setText(null);}});
buttonDivision.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mValueOne = Float.parseFloat(crunchifyEditText.getText() + "");
crunchifyDivision = true;
crunchifyEditText.setText(null);});
buttonEqual.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mValueTwo = Float.parseFloat(crunchifyEditText.getText() + "");
if (crunchifyAddition == true) {
crunchifyEditText.setText(mValueOne + mValueTwo + "");
crunchifyAddition = false;}
if (mSubtract == true) {
crunchifyEditText.setText(mValueOne - mValueTwo + "");
mSubtract = false;}
if (crunchifyMultiplication == true) {
crunchifyEditText.setText(mValueOne * mValueTwo + "");
crunchifyMultiplication = false;}
if (crunchifyDivision == true) {
crunchifyEditText.setText(mValueOne / mValueTwo + "");
crunchifyDivision = false;}}});
buttonC.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText("");});
button10.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crunchifyEditText.setText(crunchifyEditText.getText() + ".");}});}

Here we have 1 EditText. It defines the type of content.

Let’s understand code little-bit more.

 Line 11 – 14: Here we created the reference of Buttons and EditText.

 Line 16: Here we created two float variable for as value1 and value2.

 Line 21: We override the method onCreate() which is the method of Activity class.

 Line 45 – 50: We set onClickListener on Button1. If we click on Button1, EditText will


display.
 We have implemented the same logic for every button.

 Line 115 – 127: Here we have set the click listener on Add button.

 Here we put the condition as, if we EditText is Null then we set EditText as empty


value. Else we add the two value which are clicked before add button clicked and after
add button clicked.
 We also set the crunchifyAddition Boolean value to True. This true represent that add
button is clicked and this will be used when user click “=” button.
 We implement the same logic for other buttons also like buttonSub, ButtonMul,
buttonDivision.
 Line 156 – 183: Here we set clickListener on “=” button. Here we put condition like if
user click Add button the crunchifyAddition value is set True on the click listener of Add
button.
CONCLUSION
Python should be used as the first year teaching language. If used it will be
possible to teach students more programming and less of the peculiarities of
a particular language. Teaching a mid-level language like C in just one day is
inadvisable. Too much time must be spent teaching C and not enough time
teaching generic skills to students with no programming experience.

I believe the trial has shown conclusively that it is both possible and desirable to
use Python as the principal teaching language:

 It is Free (as in both cost and source code).


 It is trivial to install on a Windows PC allowing students to take their
interest further. For many the hurdle of installing a Pascal or C compiler on a
Windows machine is either too expensive or too complicated.
 It is a flexible tool that allows both the teaching of traditional procedural
programming and modern OOP, It can be used to teach a large number of
transferable skills.
 It is a real-world programming language that can be and is used in academia
and the commercial world.
 It appears to be quicker to learn and, in combination with its many libraries,
this offers the possibility of more rapid student development allowing the
course to be made more challenging and varied.

You might also like