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

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculator_2_10);
    }
    public void calculation(View v){
        EditText meterss = findViewById(R.id.beam_meters);
        EditText deniars = findViewById(R.id.beam_deniar);
        EditText bons = findViewById(R.id.beam_bon);
        EditText beamcounts = findViewById(R.id.beam_count);
        TextView beamweight = findViewById(R.id.beam_weight);
        TextView totalweight = findViewById(R.id.beam_total_count);


        try{
            Toast.makeText(this.getApplicationContext(),"필요 값을 입력 해주세요",Toast.LENGTH_LONG).show();

            float meters = Float.parseFloat(meterss.getText().toString());
            float deniar = Float.parseFloat(deniars.getText().toString());
            float bon = Float.parseFloat(bons.getText().toString());
            float beamcount = Float.parseFloat(beamcounts.getText().toString());

            double calcul1 = meters*bon/9000*deniar/1000;
            double calcul2 = beamcount*calcul1;
            double calculround1 = Math.round(calcul1*10)/10.0;
            double calculround2 = Math.round(calcul2*10)/10.0;
            beamweight.setText(calculround1+"kg");
            totalweight.setText(calculround2+"kg");
        }catch (NumberFormatException e){
            Toast.makeText(this.getApplicationContext(),"값을 제대로 입력해 주세요", Toast.LENGTH_LONG).show();
        }

    }


}
