Notes
Notes - notes.io |
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Button;
import android.widget.Toast;
public class Ana extends Activity implements OnClickListener {
Button btn0;
Button btn1;
Button btn2;
Button btn3;
Button btn4;
Button btn5;
Button btn6;
Button btn7;
Button btn8;
Button btn9;
Button btnTopla;
Button btnCikar;
Button btnCarp;
Button btnBol;
Button btnNokta;
Button btnSil;
Button btnHesapla;
Button btnKapat;
TextView txtHesap;
private double ilkDeger=0.0, sonuc=0.0;
private String islem;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ana);
btn0 = (Button) findViewById(R.id.btn0);
btn1 = (Button) findViewById(R.id.btn1);
btn2 = (Button) findViewById(R.id.btn2);
btn3 = (Button) findViewById(R.id.btn3);
btn4 = (Button) findViewById(R.id.btn4);
btn5 = (Button) findViewById(R.id.btn5);
btn6 = (Button) findViewById(R.id.btn6);
btn7 = (Button) findViewById(R.id.btn7);
btn8 = (Button) findViewById(R.id.btn8);
btn9 = (Button) findViewById(R.id.btn9);
btnTopla = (Button) findViewById(R.id.btnTopla);
btnCikar = (Button) findViewById(R.id.btnCikar);
btnBol = (Button) findViewById(R.id.btnBol);
btnCarp = (Button) findViewById(R.id.btnCarp);
btnNokta = (Button) findViewById(R.id.btnNokta);
btnHesapla=(Button) findViewById(R.id.btnHesapla);
btnSil=(Button) findViewById(R.id.btnSil);
txtHesap = (TextView) findViewById(R.id.txtHesap);
btnKapat = (Button) findViewById(R.id.btnKapat);
btn0.setOnClickListener(this);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
btn4.setOnClickListener(this);
btn5.setOnClickListener(this);
btn6.setOnClickListener(this);
btn7.setOnClickListener(this);
btn8.setOnClickListener(this);
btn9.setOnClickListener(this);
btnTopla.setOnClickListener(this);
btnCikar.setOnClickListener(this);
btnBol.setOnClickListener(this);
btnCarp.setOnClickListener(this);
btnSil.setOnClickListener(this);
btnNokta.setOnClickListener(this);
btnHesapla.setOnClickListener(this);
btnKapat.setOnClickListener(this);
}
@Override
public void onClick(View src) {
int hane=txtHesap.getText().length();
if (hane<9){
switch (src.getId()){
case R.id.btn0: txtHesap.setText(txtHesap.getText().toString()+"0"); break;
case R.id.btn1: txtHesap.setText(txtHesap.getText().toString()+"1"); break;
case R.id.btn2: txtHesap.setText(txtHesap.getText().toString()+"2"); break;
case R.id.btn3: txtHesap.setText(txtHesap.getText().toString()+"3"); break;
case R.id.btn4: txtHesap.setText(txtHesap.getText().toString()+"4"); break;
case R.id.btn5: txtHesap.setText(txtHesap.getText().toString()+"5"); break;
case R.id.btn6: txtHesap.setText(txtHesap.getText().toString()+"6"); break;
case R.id.btn7: txtHesap.setText(txtHesap.getText().toString()+"7"); break;
case R.id.btn8: txtHesap.setText(txtHesap.getText().toString()+"8"); break;
case R.id.btn9: txtHesap.setText(txtHesap.getText().toString()+"9"); break;
case R.id.btnNokta: txtHesap.setText(txtHesap.getText().toString()+"."); break;
case R.id.btnTopla:
if (!txtHesap.getText().toString().equals(""))
{
ilkDeger =Double.parseDouble(txtHesap.getText().toString());
txtHesap.setText("");
islem="Toplama";
}
else
{
Toast.makeText(this,"Aklılı insan Değer yaz", Toast.LENGTH_SHORT).show();
}
break;
case R.id.btnCikar:
if (!txtHesap.getText().toString().equals(""))
{
ilkDeger =Double.parseDouble(txtHesap.getText().toString());
txtHesap.setText("");
islem="Cikarma";
}
else
{
Toast.makeText(this,"Aklılı insan Değer yaz", Toast.LENGTH_SHORT).show();
}
break;
case R.id.btnCarp:
if (!txtHesap.getText().toString().equals(""))
{
ilkDeger =Double.parseDouble(txtHesap.getText().toString());
txtHesap.setText("");
islem="Carpma";
}
else
{
Toast.makeText(this,"Aklılı insan Değer yaz", Toast.LENGTH_SHORT).show();
}
break;
case R.id.btnBol:
if (!txtHesap.getText().toString().equals(""))
{
ilkDeger =Double.parseDouble(txtHesap.getText().toString());
txtHesap.setText("");
islem="Bolme";
}
else
{
Toast.makeText(this,"Aklılı insan Değer yaz", Toast.LENGTH_SHORT).show();
}
break;
case R.id.btnSil:
ilkDeger =0.0;
sonuc=0.0;
txtHesap.setText("");
islem="";
case R.id.btnHesapla:
if (!txtHesap.getText().toString().equals("")&&!String.valueOf(ilkDeger).equals("0.0"))
{
if (islem.equals("Toplama"))
{
sonuc = ilkDeger + Double.parseDouble(txtHesap.getText().toString());
}
else if (islem.equals("Cıkarma"))
{
sonuc = ilkDeger - Double.parseDouble(txtHesap.getText().toString());
}
else if (islem.equals("Carpma"))
{
sonuc = ilkDeger * Double.parseDouble(txtHesap.getText().toString());
}
else if (islem.equals("Bolme"))
{
sonuc=ilkDeger / Double.parseDouble(txtHesap.getText().toString());
}
txtHesap.setText(String.valueOf(sonuc));
ilkDeger=0.0;
sonuc=0.0;
islem="";
} else
{
Toast.makeText(this,"Değer Girdiniz",Toast.LENGTH_SHORT).show();
}
break;
}
} else {
Toast.makeText(this,"Lütfen 9 haneden küçük değer giriniz",Toast.LENGTH_SHORT).show();
}
if (src.getId()==R.id.btnKapat) { System.exit(0); }
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team