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

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

    }

    public void gram_calculation1(View v){
        try{
            EditText grams = findViewById(R.id.gram_1);
            EditText inchs = findViewById(R.id.inch_1);
            TextView weight = findViewById(R.id.yard_1);
            float gram = Float.parseFloat(grams.getText().toString());
            float inch = Float.parseFloat(inchs.getText().toString());
            double calcul = (gram/100)*inch*2.54*91.438/100;
            double calculround = Math.round(calcul*10)/10.0;
            weight.setText(calculround+"g/y");
        }catch (NumberFormatException e){
            Toast.makeText(this.getApplicationContext(),"값을 제대로 입력해 주세요", Toast.LENGTH_LONG).show();
        }

    }
    public void gram_calculation2(View v){
        try{
            EditText grams = findViewById(R.id.gram_2);
            EditText inchs = findViewById(R.id.inch_2);
            TextView weight = findViewById(R.id.yard_2);
            float gram = Float.parseFloat(grams.getText().toString());
            float inch = Float.parseFloat(inchs.getText().toString());
            double calcul = (gram/100)*inch*2.54*100/100;
            double calculround = Math.round(calcul*10)/10.0;
            weight.setText(calculround+"g/m");
        }catch (NumberFormatException e){
            Toast.makeText(this.getApplicationContext(),"값을 제대로 입력해 주세요", Toast.LENGTH_LONG).show();
        }

    }
    public void gram_calculation3(View v){
        try{
            EditText grams = findViewById(R.id.gram_3);
            EditText inchs = findViewById(R.id.inch_3);
            TextView weight = findViewById(R.id.paper_weight1);
            float gram = Float.parseFloat(grams.getText().toString());
            float inch = Float.parseFloat(inchs.getText().toString());
            double calcul = gram*inch*2.54*91.438/100;
            double calculround = Math.round(calcul*10)/10.0;
            weight.setText(calculround+"g/y");
        }catch (NumberFormatException e){
            Toast.makeText(this.getApplicationContext(),"값을 제대로 입력해 주세요", Toast.LENGTH_LONG).show();
        }

    }
    public void gram_calculation4(View v){
        try{
            EditText grams = findViewById(R.id.gram_4);
            EditText inchs = findViewById(R.id.inch_4);
            TextView weight = findViewById(R.id.paper_weight2);
            float gram = Float.parseFloat(grams.getText().toString());
            float inch = Float.parseFloat(inchs.getText().toString());
            double calcul = gram*inch*2.54*100/100;
            double calculround = Math.round(calcul*10)/10.0;
            weight.setText(calculround+"g/m");
        }catch (NumberFormatException e){
            Toast.makeText(this.getApplicationContext(),"값을 제대로 입력해 주세요", Toast.LENGTH_LONG).show();
        }

    }


}
