Advertisement
Robert_JR

DifferentVehicleCost

Apr 18th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.71 KB | None | 0 0
  1. //Rijoanul Hasan Shanto
  2. //Thursday, April 19, 2018
  3.  
  4. package com.example.robert_jr.visitdifferentplace;
  5.  
  6. import android.support.v7.app.AppCompatActivity;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.Button;
  10. import android.widget.EditText;
  11. import android.widget.TextView;
  12.  
  13. public class MainActivity extends AppCompatActivity {
  14.  
  15.     private Button btnMotor;
  16.     private Button btnTaxi;
  17.     private Button btnBus;
  18.  
  19.     private EditText edtInput;
  20.  
  21.     private TextView txtResult;
  22.  
  23.     @Override
  24.     protected void onCreate(Bundle savedInstanceState) {
  25.         super.onCreate(savedInstanceState);
  26.         setContentView(R.layout.activity_main);
  27.  
  28.         btnMotor = (Button) findViewById(R.id.btnMotor);
  29.         btnBus = (Button) findViewById(R.id.btnBus);
  30.         btnTaxi= (Button) findViewById(R.id.btnTaxi);
  31.  
  32.         edtInput = (EditText)findViewById(R.id.edtInput);
  33.  
  34.         txtResult = (TextView) findViewById(R.id.txtResult);
  35.  
  36.         btnMotor.setOnClickListener(new View.OnClickListener() {
  37.             @Override
  38.             public void onClick(View v) {
  39.  
  40.                 String SInput = edtInput.getText().toString();
  41.  
  42.                 if(!SInput.equals(""))
  43.                 {
  44.                     double input = Double.parseDouble(edtInput.getText().toString());
  45.  
  46.                     double res = input * 200;
  47.  
  48.                     txtResult.setText(String.valueOf(res)+" Taka");
  49.                 }
  50.                 else txtResult.setText("No input detected!");
  51.             }
  52.         });
  53.  
  54.         btnTaxi.setOnClickListener(new View.OnClickListener() {
  55.             @Override
  56.             public void onClick(View v) {
  57.                 String SInput = edtInput.getText().toString();
  58.  
  59.                 if(SInput.length() > 0 && !SInput.equals(""))
  60.                 {
  61.                     double input = Double.parseDouble(edtInput.getText().toString());
  62.  
  63.                     double res = input * 100;
  64.  
  65.                     txtResult.setText(String.valueOf(res)+" Taka");
  66.                 }
  67.                 else txtResult.setText("No input detected!");
  68.             }
  69.         });
  70.  
  71.         btnBus.setOnClickListener(new View.OnClickListener() {
  72.             @Override
  73.             public void onClick(View v) {
  74.                 String SInput = edtInput.getText().toString();
  75.  
  76.                 if(SInput.length() > 0 && !SInput.equals(""))
  77.                 {
  78.                     double input = Double.parseDouble(edtInput.getText().toString());
  79.  
  80.                     double res = input * 50;
  81.  
  82.                     txtResult.setText(String.valueOf(res)+" Taka");
  83.                 }
  84.                 else txtResult.setText("No input detected!");
  85.             }
  86.         });
  87.  
  88.  
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement