(Solved Homework): How to program a simple calculator using Android Studio? My code so far in XML:…

How to program a simple calculator using Android Studio? My code so far in XML:

xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.gangstatop.calculator.MainActivity"
    tools:layout_editor_absoluteY="90dp"
    tools:layout_editor_absoluteX="0dp">


    <TextView
        android:id="@+id/outPut"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:text="TextView"
        android:textAlignment="viewEnd"
        tools:layout_constraintTop_creator="1"
        tools:layout_constraintRight_creator="1"
        android:layout_marginEnd="39dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="39dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginRight="39dp" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="255dp"
        android:orientation="vertical"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout_constraintRight_creator="1"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        tools:layout_constraintLeft_creator="1"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >

            <Button
                android:id="@+id/clear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="AC" />

            <Button
                android:id="@+id/plusorminus"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="+/-" />

            <Button
                android:id="@+id/backspace"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="<-" />

            <Button
                android:id="@+id/divide"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="÷" />
        LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/seven"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="7" />

            <Button
                android:id="@+id/eight"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="8" />

            <Button
                android:id="@+id/nine"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="9" />

            <Button
                android:id="@+id/multi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="*" />
        LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/four"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="4" />

            <Button
                android:id="@+id/five"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="5" />

            <Button
                android:id="@+id/six"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="6" />

            <Button
                android:id="@+id/minus"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="-" />
        LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <Button
                android:id="@+id/one"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="1" />

            <Button
                android:id="@+id/two"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="2" />

            <Button
                android:id="@+id/three"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="3" />

            <Button
                android:id="@+id/plus"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="+" />

        LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/zero"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="0" />

            <Button
                android:id="@+id/dot"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="." />

            <Button
                android:id="@+id/equal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="=" />

        LinearLayout>

    LinearLayout>

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:text="TextView"
        android:textAlignment="viewEnd"
        tools:layout_constraintTop_creator="1"
        tools:layout_constraintRight_creator="1"
        android:layout_marginEnd="39dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="39dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginRight="39dp" />
android.support.constraint.ConstraintLayout>   Then my main activity code: 


package com.example.gangstatop.calculator;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Button;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {

    private Button button0, button1, button2, button3, button4, button5, button6, button7, button8, button9;
    private Button buttonAdd, buttonSub, buttonMulitiply, buttonDivide, buttonBack, buttonClear, buttonSwitch, buttonPeriod, buttonEqual;
    private TextView results, finalResults;
    private double firstValue, secondValue;
    private char OPERATION;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        initialize();

        results.setText("0");
        finalResults.setText("");
        pressButton();





    }

    private void initialize() {
        //Number buttons
        button0 = (Button)findViewById(R.id.zero);
        button1 = (Button)findViewById(R.id.one);
        button2 = (Button)findViewById(R.id.two);
        button3 = (Button)findViewById(R.id.three);
        button4 = (Button)findViewById(R.id.four);
        button5 = (Button)findViewById(R.id.five);
        button6 = (Button)findViewById(R.id.six);
        button7 = (Button)findViewById(R.id.seven);
        button8 = (Button)findViewById(R.id.eight);
        button9 = (Button)findViewById(R.id.nine);

        //Function buttons
        buttonAdd = (Button)findViewById(R.id.plus);
        buttonSub = (Button)findViewById(R.id.minus);
        buttonMulitiply = (Button)findViewById(R.id.multi);
        buttonDivide = (Button)findViewById(R.id.divide);

        //Misc function buttons
        buttonSwitch = (Button)findViewById(R.id.plusorminus);
        buttonClear = (Button)findViewById(R.id.clear);
        buttonPeriod = (Button)findViewById(R.id.dot);
        buttonEqual = (Button)findViewById(R.id.equal);

        //Textview displaying results
        results = (TextView)findViewById(R.id.outPut);
        finalResults = (TextView)findViewById(R.id.textView);
    }

    public void pressButton () {
        /************************************************************
         * Override the onClick function to display all numbers in
         * calculator.
         */

        //results.setText("");

        button0.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                results.setText(results.getText().toString() + "0");
            }}
        );

        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                results.setText(results.getText().toString() + "1");
            }}
        );

        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v){
                results.setText(results.getText().toString() + "2");
            }}
        );
        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                results.setText(results.getText().toString() + "3");
            }}
        );

        button4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v){
                results.setText(results.getText().toString() + "4");
            }}
        );
        button5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                results.setText(results.getText().toString() + "5");
            }}
        );

        button6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v){
                results.setText(results.getText().toString() + "6");
            }}
        );
        button7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                results.setText(results.getText().toString() + "7");
            }}
        );

        button8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v){
                results.setText(results.getText().toString() + "8");
            }}
        );

        button9.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v){
                results.setText(results.getText().toString() + "9");
            }}
        );

        buttonAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v){
                operation();
                OPERATION = '+';
                finalResults.setText(String.valueOf(firstValue));
                results.setText(null);
            }}
        );


      /* buttonBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v){
                if (results.length() > 0)  {
                    CharSequence digit = results.getText().toString();
                    results.setText(digit.subSequence(0, digit.length()-1));
                }
                else {
                    results.setText("0");
                    finalResults.setText("null");

                }
            }}
        ); */



    }

    public void operation () {
        firstValue = Double.parseDouble(results.getText().toString());
        secondValue = Double.parseDouble(results.getText().toString());

        switch (OPERATION) {
            case '+':
                firstValue = firstValue - secondValue;
                break;
            case '-':
                firstValue = firstValue - secondValue;
                break;
            case '*':
                firstValue = firstValue * secondValue;
            break;
            case '/':
                firstValue = firstValue / secondValue;
            case '=':
            break;


        }

    }




}  

manifest file: 
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.gangstatop.calculator">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        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>  
Test cases: 

1. 5+2=7
2. 6-3=3
3. 4*8=32
4. 15/3=5
5. -1.5+6=4.5
6. 19 – 27.2 = -8.2
7. 55555 * 99999 = 5.555444e9 8. 1 / 10000000 = 1e-7

Don't use plagiarized sources. Get Your Custom Essay on
(Solved Homework): How to program a simple calculator using Android Studio? My code so far in XML:…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

9. 56+34+14+5.5=109.5
10. 44 + (Clear) 13 + 45(backspace) = 17 (Should compute 13 + 4)

Expert Answer

 

activity_main

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.varun.basiccalculator.MainActivity"
    tools:layout_editor_absoluteY="90dp"
    tools:layout_editor_absoluteX="0dp">
    <TextView
        android:id="@+id/outPut"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:text="TextView"
        android:textAlignment="viewEnd"
        tools:layout_constraintTop_creator="1"
        tools:layout_constraintRight_creator="1"
        android:layout_marginEnd="39dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginRight="39dp"
        tools:layout_editor_absoluteY="39dp" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="255dp"
        android:orientation="vertical"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout_constraintRight_creator="1"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        tools:layout_constraintLeft_creator="1"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/clear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="onClickClear"
                android:text="AC" />

            <Button
                android:id="@+id/plusorminus"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="OnClickOperator"
                android:text="+/-" />

            <Button
                android:id="@+id/backspace"
                android:onClick="onClickClear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="C" />

            <Button
                android:id="@+id/divide"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="OnClickOperator"
                android:text="/" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/seven"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="onClickNumber"
                android:layout_weight="1"
                android:text="7" />

            <Button
                android:id="@+id/eight"
                android:layout_width="wrap_content"
                android:onClick="onClickNumber"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="8" />

            <Button
                android:id="@+id/nine"
                android:layout_width="wrap_content"
                android:onClick="onClickNumber"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="9" />

            <Button
                android:id="@+id/multi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="OnClickOperator"
                android:text="*" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/four"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="onClickNumber"
                android:layout_weight="1"
                android:text="4" />

            <Button
                android:id="@+id/five"
                android:onClick="onClickNumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="5" />

            <Button
                android:id="@+id/six"
                android:onClick="onClickNumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="6" />

            <Button
                android:id="@+id/minus"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="OnClickOperator"
                android:text="-" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <Button
                android:id="@+id/one"
                android:onClick="onClickNumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="1" />

            <Button
                android:id="@+id/two"
                android:onClick="onClickNumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="2" />

            <Button
                android:id="@+id/three"
                android:onClick="onClickNumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="3" />

            <Button
                android:id="@+id/plus"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="OnClickOperator"
                android:text="+" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/zero"
                android:layout_width="wrap_content"
                android:onClick="onClickNumber"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="0" />

            <Button
                android:id="@+id/dot"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="OnClickOperator"
                android:text="." />

            <Button
                android:id="@+id/equal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="onClickEqual"
                android:text="=" />

        </LinearLayout>
        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="end"
            android:text="TextView"
            android:textAlignment="viewEnd"
            tools:layout_constraintTop_creator="1"
            tools:layout_constraintRight_creator="1"
            android:layout_marginEnd="39dp"
            app:layout_constraintRight_toRightOf="parent"
            android:layout_marginTop="39dp"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginRight="39dp" />
    </LinearLayout>

</android.support.constraint.ConstraintLayout>

java file MainActivity

package com.example.varun.basiccalculator;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.regex.Pattern;

public class MainActivity extends AppCompatActivity {
    private Button button0, button1, button2, button3, button4, button5, button6, button7, button8, button9;
    private Button buttonAdd, buttonSub, buttonMulitiply, buttonDivide, buttonBack, buttonClear, buttonSwitch, buttonPeriod, buttonEqual,buttondot;
    private TextView results, finalResults;
    private double firstValue, secondValue;
    private char OPERATION;
    private TextView screen;
    private String display= "";
    private String currentOperator = "";
    private String result= "";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        screen = (TextView)findViewById(R.id.outPut);
        screen.setText(display);
        buttonBack = (Button)findViewById(R.id.clear);
    }
    private void updateScreen(){
        screen.setText(display);
    }
    public void onClickNumber(View v){
        if(result != ""){
            clear();
            updateScreen();
        }
        Button b = (Button) v;
        display += b.getText();
        updateScreen();
    }
    private boolean isOperator(char op){
        switch (op){
            case '+':
            case '-':
            case 'x':
            case '÷':return true;
            default: return false;
        }
    }
    public void OnClickOperator(View v){
        if(display == "") return;

        Button b = (Button)v;

        if(result != ""){
            String _display = result;
            clear();
            display = _display;
        }

        if(currentOperator != ""){
           if(isOperator(display.charAt(display.length()-1))){
                display = display.replace(display.charAt(display.length()-1), b.getText().charAt(0));
                updateScreen();
                return;
            }else{
                getResult();
                display = result;
                result = "";
            }
            currentOperator = b.getText().toString();
        }
        display += b.getText();
        currentOperator = b.getText().toString();
        updateScreen();
    }

    private void clear(){
        display = "";
        currentOperator = "";
        result = "";
    }

    public void onClickClear(View v) {
        clear();
        updateScreen();
    }
    public void OnClickBack(){
        display.substring(0,display.length()-1);
        updateScreen();
    }
    private double operate(String a, String b, String op){
        switch (op){
            case "+": return Double.valueOf(a) + Double.valueOf(b);
            case "-": return Double.valueOf(a) - Double.valueOf(b);
            case "*": return Double.valueOf(a) * Double.valueOf(b);
            case "÷": try{
                return Double.valueOf(a) / Double.valueOf(b);
            }catch (Exception e){
               // Log.d("Calc", e.getMessage());
            }
            case "+/-": return Double.valueOf(a) * -1;
            default: return -1;
        }
    }

    private boolean getResult(){
        if(currentOperator == "") return false;
        String[] operation = display.split(Pattern.quote(currentOperator));
         if(operation.length < 2) return false;
        result = String.valueOf(operate(operation[0], operation[1], currentOperator));
        return true;
    }

    public void onClickEqual(View v){
        if(display == "") return;
        if(!getResult()) return;
        screen.setText(display + "n" + String.valueOf(result));
    }
}

Homework Ocean
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents