Top Banner

of 8

Pb t Android

Aug 07, 2018

Download

Documents

Ryan Miller
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/20/2019 Pb t Android

    1/17

     

    POLITEKNIK KUCHING SARAWAK

    KM 22, JALAN MATANG,

    93050 KUCHING, SARAWAK

    TEL: 082-845596

    http://www.poliku.edu.my

    INFORMATION TECHNOLOGY &

    COMMUNICATION DEPARTMENT

    FP533: MOBILE APPLICATION DEVELOPMENT 

    PROBLEM BASED TASK REPORT BASIC CALCULATOR

    PREPARED BY:

    NURUL ALIAH SYAHIDAH BINTI HUT 05DIP13F2018

    NURNADYRA AFYZZA BINTI SUZALEE 05DIP13F2030

    LECTURER’S NAME:

    MR ZAKIR HUSSAIN

  • 8/20/2019 Pb t Android

    2/17

     

    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 calculator app, these invention are not only for the calculation purpose just like the 

    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 

    bringing the electronic calculator device for all the time.

    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 

    operations that are provided one of the interfaces to get the total of their calculations.

     Android Studio software is being used to develop this application. We have used 

    Ice Cream Sandwich 4.0 and SDK 15.

  • 8/20/2019 Pb t Android

    3/17

     

    SOURCE CODE:

    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;

     public class MainActivity extends AppCompatActivity {

     private EditText num1 

    , num2;

    @Override

     protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.  activity_main);

    num1 = (EditText) findViewById(R.id. 

    editText  );

    num2 = (EditText) findViewById(R.id. editText2 );

    }

    @Override

  • 8/20/2019 Pb t Android

    4/17

       public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar

    if it is present.

    getMenuInflater().inflate(R.menu. 

     menu_main, menu);

    return true ;

    }

    @Override

     public boolean onOptionsItemSelected(MenuItem item) {

    // Handle action bar item clicks here. The action bar

    will

    // automatically handle clicks on the Home/Up button, so

    long

    // as you specify a parent activity in

    AndroidManifest.xml.

    int id = item.getItemId();

    //noinspection SimplifiableIfStatement

    if (id == R.id.action_settings 

    ) {

    return true;

    }

    return super .onOptionsItemSelected(item);

    }

     public void sumar (View v){

    int n1 = Integer. 

     parseInt 

    (num1 

    .getText().toString());

    int n2 = Integer. 

     parseInt (num2 

    .getText().toString());

    int total = n1 + n2;

    mostrar (total);

    }

  • 8/20/2019 Pb t Android

    5/17

     

     public void restar (View v){

    int n1 = Integer. 

     parseInt (num1 

    .getText().toString());

    int n2 = Integer. 

     parseInt (num2 

    .getText().toString());

    int total = n1 - n2;

    mostrar (total);

    }

     public void multiplicar (View v){

    int n1 = Integer.   parseInt (num1  .getText().toString());

    int n2 = Integer. 

     parseInt (num2 

    .getText().toString());

    int total = n1 * n2;

    mostrar (total);

    }

     public void dividir (View v){

    int n1 = Integer.   parseInt (num1  .getText().toString());

    int n2 = Integer. 

     parseInt (num2 

    .getText().toString());

    int total = 0;

    if (n2

  • 8/20/2019 Pb t Android

    6/17

      Toast. 

    makeText 

    (MainActivity. 

    this 

    , "Total = " 

    + total,

    Toast. LENGTH_LONG  ).show();

    }

    }

  • 8/20/2019 Pb t Android

    7/17

     

    activity_main.xml

    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" />

  • 8/20/2019 Pb t Android

    8/17

     

    TextView

    android  

    :layout_width= 

    "wrap_content"

    android  

    :layout_height="wrap_content"

    android  

    :text= 

    "@string/number2"

    android  

    :id="@+id/textView2" />

    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" />

  • 8/20/2019 Pb t Android

    9/17

     

    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" />

     

  • 8/20/2019 Pb t Android

    10/17

     

    AndroidManifest.xml

     manifest

    xmlns: 

    android = 

    "http://schemas.android.com/apk/res/android"

     package= 

    "leya.example.org.basiccalculator" >

    activity

    android  

    :name= 

    ".MainActivity"

    android  

    :label="@string/app_name" >

    action

    android :name="android.intent.action.MAIN" />

    category

    android :name="android.intent.category.LAUNCHER" />

  • 8/20/2019 Pb t Android

    11/17

     

    strings.xml

    resources>

    BasicCalculator

    Settings

    Number 1:

    Number 2:

    +

    -

    *

    /

  • 8/20/2019 Pb t Android

    12/17

     

    OUTPUT:

    Interface

    Figure 1.0: The above figure shows the interface of the calculator

    The calculator consists of four different kinds of arithmetic operations which are 

    addition, subtraction, multiplication and division. The user need to ‘touch’ the EditText in 

    Number 1 to fill in the number 16 and next,Number 2 for the number 52.After fill the both 

    numbers.user can choose any operation to get total. 

  • 8/20/2019 Pb t Android

    13/17

     

    Process 1: Addition

    Figure 1.2: The above figure shows the process of addition

    For the first process,when the user enter the number 12 for the first empty space and the fill the second empty space with number 11,after that user will click on the 

    addition to get the total for both number.When the process addition success, the dialog 

    pop up the total of both number is 23.

  • 8/20/2019 Pb t Android

    14/17

     

    Process 2: Subtraction

    Figure 1.3: The above figure shows the process of subtraction

    For the second,when the user enter the number 25 for the first empty space and 

    the fill the second empty space with number 11,after that user will click on the addition 

    to get the total for both number.When the process subtraction is successful, the dialog 

    pop up the total of both number is 14.

  • 8/20/2019 Pb t Android

    15/17

     

    Process 3: Multiplication

    Figure 1.4: The above figure shows the process of multiplication

    Next,for the third process,when the user enter the number 15 for the first empty 

    space and the fill the second empty space with number 11,after that user will click on 

    the addition to get the total for both number.When the process subtraction is successful, 

    the dialog pop up the total of both number is 165.  

  • 8/20/2019 Pb t Android

    16/17

     

    Process 4: Division

    Figure 1.5: The above figure shows the process of division

    Finally for the last process,when the user enter the number 15 for the first empty 

    space and the fill the second empty space with number 5,after that user will click on the 

    addition to get the total for both number.When the process division is successful, the 

    dialog pop up the total of both number is 3. 

  • 8/20/2019 Pb t Android

    17/17

     

    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 in our marketable when as we can see almost all touch 

    screen handphone have these calculator.These can make user can take anywhere and 

    use everywhere and anytime.

    The benefits this invention can improve our productivity as human being to 

    successful in life because day by day will be come out with another invention so these 

    will be the first enhancement for the inventor to brainstorm their idea to create a 

    different idea for the future.