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

    EditText paperinchs;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculator_1_8);
        paperinchs = findViewById(R.id.paperinch);
        paperinchs.requestFocus();

    }
    public void papercal(View v){

        try{

            EditText paperwales = findViewById(R.id.paperwale);
            EditText paperwidths = findViewById(R.id.paperwidth);
            TextView papermake = findViewById(R.id.papermakewidth);
            float paperindch = Float.parseFloat(paperinchs.getText().toString());
            float paperwale = Float.parseFloat(paperwales.getText().toString());
            float paperwidth = Float.parseFloat(paperwidths.getText().toString());
            double calcul = paperindch*2.54*paperwale/paperwidth;
            double calculround = Math.round(calcul*10)/10.0;

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

    }

}
