package com.example.calcutator.Calculator1;

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.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Calculator_1_2 extends AppCompatActivity {

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

    }

    public void day_calculation(View v){
        EditText earnings = findViewById(R.id.day_earnings);
        EditText rpm = findViewById(R.id.day_rpm);
        EditText destiny = findViewById(R.id.day_destiny);
        EditText runtime = findViewById(R.id.day_runtime);
        EditText efficiency = findViewById(R.id.day_efficiency);
        EditText width_count = findViewById(R.id.day_width_count);
        TextView beamweight = findViewById(R.id.day_output);
        TextView totalweight = findViewById(R.id.day_pay);

        try {
            double day_earnings = Float.parseFloat(earnings.getText().toString());
            double day_rpm = Float.parseFloat(rpm.getText().toString());
            double day_destiny = Float.parseFloat(destiny.getText().toString());
            double day_runtime = Float.parseFloat(runtime.getText().toString());
            double day_efficiency = Float.parseFloat(efficiency.getText().toString());
            double day_width_count = Float.parseFloat(width_count.getText().toString());


            double calcul1 = day_rpm * 60 / day_destiny / 91.44 * day_runtime * (day_efficiency / 100) * day_width_count;
            double calcul2 = day_earnings / calcul1;
            double calculround1 = Math.round(calcul1);
            double calculround2 = Math.round(calcul2);

        beamweight.setText(calculround1+"yds");
        totalweight.setText(calculround2+"원");
        }catch (NumberFormatException e){
            Toast.makeText(this.getApplicationContext(),"값을 제대로 입력해 주세요", Toast.LENGTH_LONG).show();
        }catch (NullPointerException e){

        }
    }

}
