package com.example.calcutator.Calculator1;

import android.os.Bundle;

import com.example.calcutator.R;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Calculator_1_12 extends AppCompatActivity {

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

    public void Density_calculation(View v){
        EditText Gear_A = findViewById(R.id.A_gear);
        EditText Gear_B = findViewById(R.id.B_gear);
        TextView Density = findViewById(R.id.Density);

        try{
            String A_Text=Gear_A.getText().toString();
            String B_Text=Gear_B.getText().toString();

                Toast.makeText(this.getApplicationContext(),"필요 값을 입력 해주세요",Toast.LENGTH_LONG).show();

                float A_Gear = Float.parseFloat(Gear_A.getText().toString());
                float B_Gear = Float.parseFloat(Gear_B.getText().toString());
                double calcul =  B_Gear/A_Gear*20.87;
                double calculround =   Math.round(calcul*100)/100.0;
                Density.setText(calculround+"cm");

        }catch (NumberFormatException e){
            Toast.makeText(this.getApplicationContext(),"값을 제대로 입력해 주세요", Toast.LENGTH_LONG).show();
        }
    }


}
