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_11 extends AppCompatActivity {

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

    }
    public void calculation1(View v){
        EditText a21s = findViewById(R.id.a21);
        EditText a30s = findViewById(R.id.a30);
        EditText a40s = findViewById(R.id.a40);
        EditText b21s = findViewById(R.id.b21);
        EditText b30s = findViewById(R.id.b30);
        EditText b40s = findViewById(R.id.b40);
        TextView rackmm21 = findViewById(R.id.rack21);
        TextView rackmm30 = findViewById(R.id.rack30);
        TextView rackmm40 = findViewById(R.id.rack40);
        try{
            float a21 = Float.parseFloat(a21s.getText().toString());
            float a30 = Float.parseFloat(a30s.getText().toString());
            float a40 = Float.parseFloat(a40s.getText().toString());
            float b21 = Float.parseFloat(b21s.getText().toString());
            float b30 = Float.parseFloat(b30s.getText().toString());
            float b40 = Float.parseFloat(b40s.getText().toString());
            double calcul1 = a21/b21*626.1;
            double calcul2 = a30/b30*834.9;
            double calcul3 = a40/b40*1240;
            double calculround1 = Math.round(calcul1);
            double calculround2 = Math.round(calcul2);
            double calculround3 = Math.round(calcul3);
            int calculch1 = (int)calculround1;
            int calculch2 = (int)calculround2;
            int calculch3 = (int)calculround3;
            rackmm21.setText(calculch1+"Rack/mm");
            rackmm30.setText(calculch2+"Rack/mm");
            rackmm40.setText(calculch3+"Rack/mm");
        }catch (NumberFormatException e){
            Toast.makeText(this.getApplicationContext(),"값을 제대로 입력해 주세요", Toast.LENGTH_LONG).show();
        }
    }
    public void calculation2(View v){
        EditText a21s = findViewById(R.id.an21);
        EditText a30s = findViewById(R.id.an30);
        EditText a40s = findViewById(R.id.an40);
        EditText b21s = findViewById(R.id.bn21);
        EditText b30s = findViewById(R.id.bn30);
        EditText b40s = findViewById(R.id.bn40);
        TextView rackmm21 = findViewById(R.id.rackn21);
        TextView rackmm30 = findViewById(R.id.rackn30);
        TextView rackmm40 = findViewById(R.id.rackn40);
        try{
            float a21 = Float.parseFloat(a21s.getText().toString());
            float a30 = Float.parseFloat(a30s.getText().toString());
            float a40 = Float.parseFloat(a40s.getText().toString());
            float b21 = Float.parseFloat(b21s.getText().toString());
            float b30 = Float.parseFloat(b30s.getText().toString());
            float b40 = Float.parseFloat(b40s.getText().toString());
            double calcul1 = a21/b21*1408.8;
            double calcul2 = a30/b30*1878.4;
            double calcul3 = a40/b40*2780;
            double calculround1 = Math.round(calcul1);
            double calculround2 = Math.round(calcul2);
            double calculround3 = Math.round(calcul3);
            int calculch1 = (int)calculround1;
            int calculch2 = (int)calculround2;
            int calculch3 = (int)calculround3;
            rackmm21.setText(calculch1+"Rack/mm");
            rackmm30.setText(calculch2+"Rack/mm");
            rackmm40.setText(calculch3+"Rack/mm");
        }catch (NumberFormatException e){
            Toast.makeText(this.getApplicationContext(),"값을 제대로 입력해 주세요", Toast.LENGTH_LONG).show();
        }

    }

}
