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;

import org.w3c.dom.Text;

public class Calculator_2_2 extends AppCompatActivity {

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

    }
    public void weaving_length_calculation(View v){
        EditText yard = findViewById(R.id.weaving_yard);
        EditText width = findViewById(R.id.weaving_width);
        EditText length = findViewById(R.id.weaving_length);
        EditText loss = findViewById(R.id.weaving_loss);
        TextView total_length=findViewById(R.id.beam_total_length);
        try{
            float weaving_yard = Float.parseFloat(yard.getText().toString());
            float weaving_width = Float.parseFloat(width.getText().toString());
            float weaving_length = Float.parseFloat(length.getText().toString());
            float weaving_loss=Float.parseFloat(loss.getText().toString());

            double calcul = weaving_yard/weaving_width*weaving_length;
            double calculround = calcul*(100+weaving_loss)/100;
            long calculround2 = Math.round(calculround);

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



    }

}
