Code Monkey home page Code Monkey logo

meter-inch-convertor-app's Introduction

METER-INCH-CONVERTOR-APP

Developed a meter inch convertor app

package com.example.metertoinches;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

private EditText EnterInMeters;
private Button Covertbutton;
private TextView Resultid;
private EditText EnterInInches;
private Button CovertButton2;
private TextView ResultId2;

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

    EnterInMeters=(EditText) findViewById(R.id.EnterInMeters);
    Resultid=(TextView) findViewById(R.id.Resultid);
    Covertbutton=(Button) findViewById(R.id.Convertbutton);
    Covertbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            double permeteravalue=39.37;
            double result=0.0;

            if(EnterInMeters.getText().toString().equals(""))
            {
                Resultid.setText(R.string.Error_Message);
                Resultid.setTextColor(Color.RED);
            }
            else
            {
                double getEditText=Double.parseDouble(EnterInMeters.getText().toString());
                result=getEditText*permeteravalue;

                Resultid.setTextColor(Color.DKGRAY);
                Resultid.setText(String.format("%.2f",result)+" Inches");
            }

        }
    });

    EnterInInches=(EditText) findViewById(R.id.EnterInInches);
    ResultId2=(TextView) findViewById(R.id.ResultId2);
    CovertButton2=(Button) findViewById(R.id.ConvertButton2);
    CovertButton2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            double perinchavalue=0.0254;
            double result1=0.0;

            if(EnterInInches.getText().toString().equals(""))
            {

                ResultId2.setText(R.string.Error_Message);
                ResultId2.setTextColor(Color.RED);

            }
            else {
                double getEditText1 = Double.parseDouble(EnterInInches.getText().toString());
                result1 = getEditText1 * perinchavalue;

                ResultId2.setTextColor(Color.DKGRAY);
                ResultId2.setText(String.format("%.2f", result1) + " Meters");
            }
        }
    });


}

}

meter-inch-convertor-app's People

Contributors

mansisharma-mck avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.