Soru & Cevap

Fragment Hesap işlemi Yaptıramıyorum ...

22.03.2018 - 03:50

Merhaba, Elektrik Elektronik Mühendisiyim. Kendi imkanlarımla birkaç yıldır android studio üzerinde çalışıyorum fakat fragment yapısı ile fazla çalışma imkanım olmadı bir hesaplama programaı yaptırmak istiyorum click sırasında döngü boşluğa düşüyor. Çevremde bilen olmadığı için sizlerin yardımına başvurmaktayım. Lisanda kusur olduysa affola. Cevaplarınız için teşekkür ederim.

 

import android.app.Activity;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import java.io.Console;
import java.util.zip.Inflater;

 

public class HarfnotuFragment extends Fragment implements View.OnClickListener{

    Button btnhesap;
    TextView tvsonuc2,tvsonuc4,tvsonuc6,tvsonuc8,tvdeger,tvharf,tvort,tvskor,tvsonuc9,tvfark;
    EditText etvize,etbut,etsapma,etort;

    @Override
    public View onCreateView(LayoutInflater inflater,
                             ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_harfnotu,container,false);


        final EditText etvize =  getActivity().findViewById(R.id.etvize);
        final EditText etbut = getActivity().findViewById(R.id.etbut);
        final EditText etsapma = getActivity().findViewById(R.id.etsapma);
        final EditText etort = getActivity().findViewById(R.id.etort);


        final TextView tvsonuc2 = getActivity().findViewById(R.id.tvsonuc2);
        final TextView tvdeger = getActivity().findViewById(R.id.tvdeger);
        final TextView tvsonuc4 = getActivity().findViewById(R.id.tvsonuc4);
        final TextView tvharf = getActivity().findViewById(R.id.tvharf);
        final TextView tvsonuc6 = getActivity().findViewById(R.id.tvsonuc6);
        final TextView tvort = getActivity().findViewById(R.id.tvort);
        final TextView tvsonuc8 = getActivity().findViewById(R.id.tvsonuc8);
        final TextView tvskor = getActivity().findViewById(R.id.tvskor);
        final TextView tvsonuc10 = getActivity().findViewById(R.id.tvsonuc10);
        final TextView tvfark = getActivity().findViewById(R.id.tvfark);
        return view;
    }
    
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);


        final EditText etvize = getActivity().findViewById(R.id.etvize);
        final EditText etbut = getActivity().findViewById(R.id.etbut);
        final EditText etsapma =getActivity().findViewById(R.id.etsapma);
        final EditText etort = getActivity().findViewById(R.id.etort);


        final TextView tvsonuc2 = getActivity().findViewById(R.id.tvsonuc2);
        final TextView tvdeger = getActivity().findViewById(R.id.tvdeger);
        final TextView tvsonuc4 = getActivity().findViewById(R.id.tvsonuc4);
        final TextView tvharf = getActivity().findViewById(R.id.tvharf);
        final TextView tvsonuc6 = getActivity().findViewById(R.id.tvsonuc6);
        final TextView tvort = getActivity().findViewById(R.id.tvort);
        final TextView tvsonuc8 = getActivity().findViewById(R.id.tvsonuc8);
        final TextView tvskor = getActivity().findViewById(R.id.tvskor);
        final TextView tvsonuc10 = getActivity().findViewById(R.id.tvsonuc10);
        final TextView tvfark = getActivity().findViewById(R.id.tvfark);

        btnhesap= getActivity().findViewById(R.id.btnhesap);
        btnhesap.setOnClickListener(this);
    }


    @Override
    public void onClick(View view) {

        float etvizefloat = Float.parseFloat(etvize.getText().toString());//

        float etbutfloat = Float.parseFloat(etbut.getText().toString());//
        float etsapmafloat = Float.parseFloat(etsapma.getText().toString());//
        float etortfloat = Float.parseFloat(etort.getText().toString());//

        //////////////////////////////////////////////
      float tvsonuc2float = Float.parseFloat(tvsonuc2.getText().toString());
      float tvdegerfloat = Float.parseFloat(tvdeger.getText().toString());
      float tvsonuc4float = Float.parseFloat(tvsonuc4.getText().toString());
      float tvharffloat = Float.parseFloat(tvharf.getText().toString());
      float tvsonuc6float = Float.parseFloat(tvsonuc6.getText().toString());
      float tvortfloat = Float.parseFloat(tvort.getText().toString());//vize final ortalaması
      float tvsonuc8float = Float.parseFloat(tvsonuc8.getText().toString());
      float tvskorfloat = Float.parseFloat(tvskor.getText().toString());
      float tvsonuc10float = Float.parseFloat(tvsonuc9.getText().toString());
      float tvfarkfloat = Float.parseFloat(tvfark.getText().toString());

        
        tvort.setText(String.valueOf((etvizefloat * 0.4) + (etbutfloat * 0.6)));
        tvfark.setText(String.valueOf(tvortfloat-etortfloat));
        tvskor.setText(String.valueOf((((tvfarkfloat/etsapmafloat)*10)+50)/2));
        

      String tvsonuc2= "";
      String tvharf = "";


        if (70 < etortfloat && etortfloat <= 100) {
            tvsonuc2 = "BAĞIL ÇOK İYİ";

            
            System.out.print(tvsonuc2);

            if (0 < tvortfloat && tvortfloat < 30.99) {
                tvharf = "FF";
                System.out.print(tvharf);
            } else if (31 < tvortfloat && tvortfloat < 35.99) {
                tvharf = "DD";System.out.print(tvharf);
            } else if ( tvortfloat>36 && tvortfloat < 40.99) {
                tvharf = "DC";System.out.print(tvharf);
            } else if (41 < tvortfloat && tvortfloat < 45.99) {
                tvharf = "CC";System.out.print(tvharf);
            } else if (46 < tvortfloat && tvortfloat < 50.99) {
                tvharf = "CB";System.out.print(tvharf);
            } else if (51 < tvortfloat && tvortfloat < 55.99) {
                tvharf = "BB";System.out.print(tvharf);
            } else if (56 < tvortfloat && tvortfloat < 60.99) {
                tvharf = "BA";System.out.print(tvharf);
            } else if (61 < tvortfloat && tvortfloat < 100) {
                tvharf = "AA";System.out.print(tvharf);
            }

        }

        else if (57.50 < etortfloat && etortfloat <= 62.4) {
            tvsonuc2 = "BAĞIL İYİ";

            System.out.print(tvsonuc2);

            if (0 < tvortfloat && tvortfloat < 32.99) {
                tvharf = "FF";System.out.print(tvharf);
            } else if (33 < tvortfloat && tvortfloat < 37.99) {
                tvharf = "DD";System.out.print(tvharf);
            } else if (38 < tvortfloat && tvortfloat < 42.99) {
                tvharf = "DC";System.out.print(tvharf);
            } else if (43 < tvortfloat && tvortfloat < 47.99) {
                tvharf = "CC";System.out.print(tvharf);
            } else if (48 < tvortfloat && tvortfloat < 52.99) {
                tvharf = "CB";System.out.print(tvharf);
            } else if (53 < tvortfloat && tvortfloat < 57.99) {
                tvharf = "BB";System.out.print(tvharf);
            } else if (58 < tvortfloat && tvortfloat < 62.99) {
                tvharf = "BA";System.out.print(tvharf);
            } else if (63 < tvortfloat && tvortfloat < 100) {
                tvharf = "AA";System.out.print(tvharf);
            }

        } else if (52.50 < etortfloat && etortfloat <= 57.49) {
            tvsonuc2 = "BAĞIL ORTANIN ÜSTÜ";
            System.out.print(tvsonuc2);

            if (0 < tvortfloat && tvortfloat < 34.99) {
                tvharf = "FF";System.out.print(tvharf);
            } else if (35 < tvortfloat && tvortfloat < 39.99) {
                tvharf = "DD";System.out.print(tvharf);
            } else if (40 < tvortfloat && tvortfloat < 44.99) {
                tvharf = "DC";System.out.print(tvharf);
            } else if (45 < tvortfloat && tvortfloat < 49.99) {
                tvharf = "CC";System.out.print(tvharf);
            } else if (50 < tvortfloat && tvortfloat < 54.99) {
                tvharf = "CB";System.out.print(tvharf);
            } else if (55 < tvortfloat && tvortfloat < 59.99) {
                tvharf = "BB";System.out.print(tvharf);
            } else if (60 < tvortfloat && tvortfloat < 64.99) {
                tvharf = "BA";System.out.print(tvharf);
            } else if (65 < tvortfloat && tvortfloat < 100) {
                tvharf = "AA";System.out.print(tvharf);
            }

        } else if (47.50 < etortfloat && etortfloat <= 52.49) {
            tvsonuc2 = "BAĞIL ORTA";
            System.out.print(tvsonuc2);

            if (0 < tvortfloat && tvortfloat < 36.99) {
                tvharf = "FF";System.out.print(tvharf);
            } else if (37 < tvortfloat && tvortfloat < 41.99) {
                tvharf = "DD";System.out.print(tvharf);
            } else if (42 < tvortfloat && tvortfloat < 46.99) {
                tvharf = "DC";System.out.print(tvharf);
            } else if (47 < tvortfloat && tvortfloat < 51.99) {
                tvharf = "CC";System.out.print(tvharf);
            } else if (52 < tvortfloat && tvortfloat < 56.99) {
                tvharf = "CB";System.out.print(tvharf);
            } else if (57 < tvortfloat && tvortfloat < 61.99) {
                tvharf = "BB";System.out.print(tvharf);
            } else if (62 < tvortfloat && tvortfloat < 66.99) {
                tvharf = "BA";System.out.print(tvharf);
            } else if (67 < tvortfloat && tvortfloat < 100) {
                tvharf = "AA";System.out.print(tvharf);
            }

        } else if (42.50 < etortfloat && etortfloat <= 47.49) {
            tvsonuc2 = "BAĞIL ZAYIF";
            System.out.print(tvsonuc2);

            if (0 < tvortfloat && tvortfloat < 38.99) {
                tvharf = "FF";System.out.print(tvharf);
            } else if (39 < tvortfloat && tvortfloat < 43.99) {
                tvharf = "DD";System.out.print(tvharf);
            } else if (44 < tvortfloat && tvortfloat < 48.99) {
                tvharf = "DC";System.out.print(tvharf);
            } else if (49 < tvortfloat && tvortfloat < 53.99) {
                tvharf = "CC";System.out.print(tvharf);
            } else if (54 < tvortfloat && tvortfloat < 58.99) {
                tvharf = "CB";System.out.print(tvharf);
            } else if (59 < tvortfloat && tvortfloat < 63.99) {
                tvharf = "BB";System.out.print(tvharf);
            } else if (64 < tvortfloat && tvortfloat < 66.99) {
                tvharf = "BA";System.out.print(tvharf);
            } else if (67 < tvortfloat && tvortfloat < 100) {
                tvharf = "AA";System.out.print(tvharf);
            }

        } else if (42.50 < etortfloat && etortfloat <= 47.49) {
            tvsonuc2 = "BAĞIL KÖTÜ";
            System.out.print(tvsonuc2);

            if (0 < tvortfloat && tvortfloat < 40.99) {
                tvharf = "FF";System.out.print(tvharf);
            } else if (41 < tvortfloat && tvortfloat < 45.99) {
                tvharf = "DD";System.out.print(tvharf);
            } else if (46 < tvortfloat && tvortfloat < 50.99) {
                tvharf = "DC";System.out.print(tvharf);
            } else if (51 < tvortfloat && tvortfloat < 55.99) {
                tvharf = "CC";System.out.print(tvharf);
            } else if (56 < tvortfloat && tvortfloat < 60.99) {
                tvharf = "CB";System.out.print(tvharf);
            } else if (61 < tvortfloat && tvortfloat < 65.99) {
                tvharf = "BB";System.out.print(tvharf);
            } else if (66 < tvortfloat && tvortfloat < 70.99) {
                tvharf = "BA";System.out.print(tvharf);
            } else if (71 < tvortfloat && tvortfloat < 100) {
                tvharf = "AA";System.out.print(tvharf);
            }


        }


    }

 


    }

 

 

 

 

 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

xml:

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <Button
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:id="@+id/btnsb"/>


            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPersonName"
                android:ems="10"
                android:id="@+id/etvize"
                android:hint="Vize Notunuz" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPersonName"
                android:ems="10"
                android:id="@+id/etbut"
                android:hint="Tahmini Bütünleme Notunuz" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="numberDecimal"
                android:ems="10"
                android:id="@+id/etsapma"
                android:hint="Final sınavında oluşan Standart Sapma" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="numberDecimal"
                android:ems="10"
                android:id="@+id/etort"
                android:hint="Final sınavında oluşan ortalama" />


            <Button
                android:layout_width="380dp"
                android:layout_height="50dp"

                android:id="@+id/btnhesap"
                android:text="Harf Notunu Hesapla" />


            <TextView
                android:text="SINIF GENEL DURUMU"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvsonuc2"
                android:textSize="30sp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvdeger"
                android:textSize="24sp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvsonuc4"
                android:text="HARF NOTUNUZ"
                android:textSize="30sp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvharf"
                android:textSize="30sp" />

            <TextView
                android:text="ORTALAMANIZ"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvsonuc6"
                android:textSize="30sp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvort"
                android:textSize="30sp" />

            <TextView
                android:text="T SKOR NOTUNUZ "
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvsonuc8"
                android:textSize="30sp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvskor"
                android:textSize="30sp" />
            <TextView
                android:text="FARK "
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvsonuc9"
                android:textSize="30sp" />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tvfark"
                android:textSize="30sp" />

        </LinearLayout>
    </ScrollView>

    />
</LinearLayout>

 

 

 

9 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-259959-1585770739.jpg
ertan.kocakoc
01.12.2019 - 03:58
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;



namespace WindowsFormsApp2

{

public partial class Form1 : Form

{

double FirstNumber;

string Operation;

public Form1()

{

InitializeComponent();

}



private void button1_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text==null)

{

textBox1.Text = "1";

}

else

{

textBox1.Text = textBox1.Text + "1";

}

}



private void button2_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text == null)

{

textBox1.Text = "0";

}

else

{

textBox1.Text = textBox1.Text + "0";

}

}



private void button3_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text == null)

{

textBox1.Text = "2";

}

else

{

textBox1.Text = textBox1.Text + "2";

}

}



private void button4_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text == null)

{

textBox1.Text = "3";

}

else

{

textBox1.Text = textBox1.Text + "3";

}

}



private void button5_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text == null)

{

textBox1.Text = "4";

}

else

{

textBox1.Text = textBox1.Text + "4";

}

}



private void button6_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text == null)

{

textBox1.Text = "5";

}

else

{

textBox1.Text = textBox1.Text + "5";

}

}



private void button7_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text == null)

{

textBox1.Text = "6";

}

else

{

textBox1.Text = textBox1.Text + "6";

}

}



private void button8_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text == null)

{

textBox1.Text = "7";

}

else

{

textBox1.Text = textBox1.Text + "7";

}

}



private void button9_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text == null)

{

textBox1.Text = "8";

}

else

{

textBox1.Text = textBox1.Text + "8";

}

}



private void button10_Click(object sender, EventArgs e)

{

if (textBox1.Text == "0" && textBox1.Text == null)

{

textBox1.Text = "9";

}

else

{

textBox1.Text = textBox1.Text + "9";

}

}



private void button11_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + ",";

}



private void button12_Click(object sender, EventArgs e)

{

FirstNumber = Convert.ToDouble(textBox1.Text);

textBox1.Text = null;

Operation = "+";

}



private void button13_Click(object sender, EventArgs e)

{

FirstNumber = Convert.ToDouble(textBox1.Text);

textBox1.Text = null;

Operation = "-";

}



private void button14_Click(object sender, EventArgs e)

{

FirstNumber = Convert.ToDouble(textBox1.Text);

textBox1.Text = null;

Operation = "*";

}



private void button15_Click(object sender, EventArgs e)

{

FirstNumber = Convert.ToDouble(textBox1.Text);

textBox1.Text = null;

Operation = "/";

}



private void button16_Click(object sender, EventArgs e)

{

double SecondNumber;

double Result;



SecondNumber = Convert.ToDouble(textBox1.Text);



if (Operation=="+")

{

Result = (FirstNumber + SecondNumber);

textBox1.Text = Convert.ToString(Result);

FirstNumber = Result;

}

if (Operation == "-")

{

Result = (FirstNumber - SecondNumber);

textBox1.Text = Convert.ToString(Result);

FirstNumber = Result;



}

if (Operation == "*")

{

Result = (FirstNumber * SecondNumber);

textBox1.Text = Convert.ToString(Result);

FirstNumber = Result;

}

if (Operation == "/")

if(SecondNumber==0)

{

textBox1.Text = "Uygulanamaz";

}

else

{

Result = (FirstNumber / SecondNumber);

textBox1.Text = Convert.ToString(Result);

FirstNumber = Result;

}

}



private void button17_Click(object sender, EventArgs e)

{

textBox1.Text = null;

}

}

}