29 05 2014
1.soru ve yanıtı
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import javax.swing.plaf.basic.BasicBorders.RadioButtonBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
public class IsciUcretleri {
private JFrame frame;
private JTextField txtSaatUcreti;
private JTextField txtHafta;
private JTextField txtFazlaMesai;
private final ButtonGroup buttonGroup = new ButtonGroup();
private JTextField txtToplamUcret;
private JTextField txtVergi;
private JTextField txtSGK;
private JTextField txtNet;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
IsciUcretleri window = new IsciUcretleri();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public IsciUcretleri() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 319);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel lblSaatUcreti = new JLabel(“Saatlik \u00DCcret:”);
lblSaatUcreti.setBounds(10, 11, 124, 14);
frame.getContentPane().add(lblSaatUcreti);
JLabel lblHaftalikCalisma = new JLabel(“Haftal\u0131k \u00C7al\u0131\u015Fma Saati:”);
lblHaftalikCalisma.setBounds(10, 36, 146, 14);
frame.getContentPane().add(lblHaftalikCalisma);
JLabel lblFazlaMesai = new JLabel(“Haftal\u0131k Fazla Mesai:”);
lblFazlaMesai.setBounds(10, 61, 146, 14);
frame.getContentPane().add(lblFazlaMesai);
JLabel lblHesapTr = new JLabel(“Hesap T\u00FCr\u00FC:”);
lblHesapTr.setBounds(300, 11, 80, 14);
frame.getContentPane().add(lblHesapTr);
txtSaatUcreti = new JTextField();
txtSaatUcreti.setBounds(166, 11, 86, 20);
frame.getContentPane().add(txtSaatUcreti);
txtSaatUcreti.setColumns(10);
txtHafta = new JTextField();
txtHafta.setBounds(166, 36, 86, 20);
frame.getContentPane().add(txtHafta);
txtHafta.setColumns(10);
txtFazlaMesai = new JTextField();
txtFazlaMesai.setBounds(166, 61, 86, 20);
frame.getContentPane().add(txtFazlaMesai);
txtFazlaMesai.setColumns(10);
final JRadioButton radioAylik = new JRadioButton(“Ayl\u0131k”);
radioAylik.setSelected(true);
buttonGroup.add(radioAylik);
radioAylik.setBounds(300, 36, 109, 23);
frame.getContentPane().add(radioAylik);
final JRadioButton radioYillik = new JRadioButton(“Y\u0131ll\u0131k”);
buttonGroup.add(radioYillik);
radioYillik.setBounds(300, 57, 109, 23);
frame.getContentPane().add(radioYillik);
JLabel lblToplamUcret = new JLabel(“Toplam \u00DCcret”);
lblToplamUcret.setBounds(10, 135, 124, 14);
frame.getContentPane().add(lblToplamUcret);
txtToplamUcret = new JTextField();
txtToplamUcret.setEditable(false);
txtToplamUcret.setColumns(10);
txtToplamUcret.setBounds(147, 132, 136, 20);
frame.getContentPane().add(txtToplamUcret);
JLabel lblVergi = new JLabel(“Vergi Kesintisi”);
lblVergi.setHorizontalAlignment(SwingConstants.LEFT);
lblVergi.setBounds(10, 160, 124, 14);
frame.getContentPane().add(lblVergi);
txtVergi = new JTextField();
txtVergi.setEditable(false);
txtVergi.setColumns(10);
txtVergi.setBounds(147, 157, 136, 20);
frame.getContentPane().add(txtVergi);
JLabel lblSGK = new JLabel(“SGK Kesintisi”);
lblSGK.setBounds(10, 185, 124, 14);
frame.getContentPane().add(lblSGK);
txtSGK = new JTextField();
txtSGK.setEditable(false);
txtSGK.setColumns(10);
txtSGK.setBounds(147, 182, 136, 20);
frame.getContentPane().add(txtSGK);
JLabel lblNet = new JLabel(“Net \u00DCcret”);
lblNet.setBounds(10, 214, 124, 14);
frame.getContentPane().add(lblNet);
txtNet = new JTextField();
txtNet.setEditable(false);
txtNet.setColumns(10);
txtNet.setBounds(147, 211, 136, 20);
frame.getContentPane().add(txtNet);
final JLabel lblMesaj = new JLabel(“”);
lblMesaj.setForeground(Color.RED);
lblMesaj.setBounds(102, 255, 181, 14);
frame.getContentPane().add(lblMesaj);
//hesapla butonuna basılınca çalışacak olan kodlar.
JButton btnHesapla = new JButton(“Hesapla”);
btnHesapla.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0)
{
lblMesaj.setText(” “);
if (!txtSaatUcreti.getText().isEmpty() && !txtHafta.getText().isEmpty() && !txtFazlaMesai.getText().isEmpty() )
{
double saatUcreti = Double.parseDouble(txtSaatUcreti.getText());
int haftaSaat=Integer.parseInt(txtHafta.getText());
int haftaFazlaMesai= Integer.parseInt(txtFazlaMesai.getText());
int normalSaat = 0;
int fazlaMesai=0;
if (radioAylik.isSelected())
{
normalSaat=haftaSaat*4;
fazlaMesai=haftaFazlaMesai*4;
}
else if (radioYillik.isSelected())
{
normalSaat=haftaSaat*52;
fazlaMesai=haftaFazlaMesai*52;
}
double toplamUcret=toplamUcret(saatUcreti, normalSaat, fazlaMesai);
double vergi=VergiKesintisi(toplamUcret);
double SGK= 0.06*(toplamUcret-vergi);
double net=toplamUcret-(vergi + SGK);
txtToplamUcret.setText(String.valueOf(toplamUcret));
txtVergi.setText(String.valueOf(vergi));
txtSGK.setText(String.valueOf(SGK));
txtNet.setText(String.valueOf(net));
}
else
lblMesaj.setText(“Lütfen alanları boş bırakmayınız!”);
}
});
btnHesapla.setBounds(163, 92, 89, 23);
frame.getContentPane().add(btnHesapla);
}
//metotlar
private static double toplamUcret(double saatUcreti, int normalSaat, int FazlaMesaiSaat)
{
double toplamUcret= (saatUcreti*normalSaat) + (saatUcreti*FazlaMesaiSaat*1.5);
return toplamUcret;
}
private static double VergiKesintisi(double toplamUcret)
{
return toplamUcret*0.35;
}
}