package com.example.calcutator.Calculator2;

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

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

    }

    public void yarnlength_calculation_1(View v){
        EditText weight = findViewById(R.id.yarnlength_length1);
        EditText denier = findViewById(R.id.yarnlength_denier);
        TextView bon = findViewById(R.id.yarnlength_bon1);


        try {
            float yarn_weight = Float.parseFloat(weight.getText().toString());
            float yarn_denier = Float.parseFloat(denier.getText().toString());
            double calcu1 = yarn_weight/9000*yarn_denier;
            double calcu1round = Math.round(calcu1);

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


    }
    public void yarnlength_calculation_2(View v){
        EditText weight = findViewById(R.id.yarnlength_length2);
        EditText dtex = findViewById(R.id.yarnlength_dtex);
        TextView bon = findViewById(R.id.yarnlength_bon2);
        try{
            float yarn_weight = Float.parseFloat(weight.getText().toString());
            float yarn_dtex = Float.parseFloat(dtex.getText().toString());
            double calcu1 = yarn_weight/10000*yarn_dtex;
            double calcu1round = Math.round(calcu1);

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

    }

}
