Created
June 22, 2017 21:27
-
-
Save AasemJS/8e1b4a03ac9e2149d5efdef661c0d426 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.aasemjs.weightconverter; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.EditText; | |
import android.widget.Toast; | |
public class MainActivity extends AppCompatActivity { | |
public void cnvPounds(View view){ | |
EditText weightInKg = (EditText) findViewById(R.id.edTxtKg); | |
String strKg = weightInKg.getText().toString(); | |
Double dblKg = Double.parseDouble(strKg); | |
Double PoundsAmount = dblKg * 2.20462; | |
Toast.makeText(getApplicationContext(), "Weight in pounds = " + PoundsAmount + "lbs", Toast.LENGTH_LONG).show(); | |
} | |
public void cnvKgs(View v){ | |
EditText weightInLbs = (EditText) findViewById(R.id.edtTxtLbs); | |
String strLbs = weightInLbs.getText().toString(); | |
Double dblLbs = Double.parseDouble(strLbs); | |
Double KgAmount = dblLbs * 0.453592; | |
Toast.makeText(getApplicationContext(), "Weight in pounds = " + KgAmount + "kg", Toast.LENGTH_LONG).show(); | |
} | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment