package com.example.calcutator.Calculator2;

import androidx.appcompat.app.AppCompatActivity;

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

import com.example.calcutator.R;

public class Calculator_2_6 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculator_2_6);
    }
    public void realyarn_calculation_1(View v){
        EditText yarnweights = findViewById(R.id.yarnWeight_1);
        EditText totallengths = findViewById(R.id.totalLength_1);
        TextView realdeniar = findViewById(R.id.readDeniar);

        try{
            float yarnweight = Float.parseFloat(yarnweights.getText().toString());
            float totallength = Float.parseFloat(totallengths.getText().toString());
            double calcu1 = yarnweight*9000/totallength;
            double calcu1round = Math.round(calcu1);

            realdeniar.setText(calcu1round+"denier");

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


    }
    public void realyarn_calculation_2(View v){
        EditText yarnweights = findViewById(R.id.yarnWeight_2);
        EditText totallengths = findViewById(R.id.totalLength_2);
        TextView realdtex = findViewById(R.id.readDtex);
        try{
            float yarnweight1 = Float.parseFloat(yarnweights.getText().toString());
            float totallength = Float.parseFloat(totallengths.getText().toString());
            double calcu2 = yarnweight1*10000/totallength;
            double calcu2round = Math.round(calcu2);

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

}
