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

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

    }

    public void totalyarn_calculation_1(View v){
        EditText weight = findViewById(R.id.totalyarn_weight1);
        EditText denier = findViewById(R.id.totalyarn_denier);
        TextView length = findViewById(R.id.totalyarn_length1);

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

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



    }
    public void totalyarn_calculation_2(View v){
        EditText weight = findViewById(R.id.totalyarn_weight2);
        EditText dtex = findViewById(R.id.totalyarn_dtex);
        TextView length = findViewById(R.id.totalyarn_length2);
        try{
            float total_weight = Float.parseFloat(weight.getText().toString());
            float total_dtex = Float.parseFloat(dtex.getText().toString());
            double calcu1 = total_weight*10000/total_dtex;
            double calcu1round = Math.round(calcu1);

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

    }

}
