Java Kod Örnekleri
16 06 2014
import java.util.Random; public class diziler { public static void main(String[] args) { int[] dizi = new int[30]; Random rnd= new Random(); int sayac=0; int toplam=0; for (int i = 0; i < 30; i++) { dizi[i]= rnd.nextInt(300)+100; //100 ile 400 arası rasgele sayı üretimi System.out.println(“dizi[” + i […]
16 06 2014
Soru 2 import java.util.Scanner; public class daireUcgen { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print(“a değerini giriniz:”); double a = sc.nextDouble(); System.out.print(“b değerini giriniz:”); double b = sc.nextDouble(); System.out.print(“c değerini giriniz:”); double c = sc.nextDouble(); double s=(a+b+c)/2; double R = (a*b*c)/(Math.sqrt((s*(s-a)*(s-b)*(s-c)))*4); System.out.println(“Sonuç: ” + R); } } […]
16 06 2014
String[] dizi = new String[2]; //combobox dolduruluyor. dizi[0] = “Santigrat”; dizi[1] = “Fahrenayt”; ComboBoxModel comboModel = new DefaultComboBoxModel(dizi); cmbCikis.setModel(comboModel); JButton btnCevir = new JButton(“\Cevir”); btnCevir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (txtSckGiris.getText().isEmpty()) //boş giriş kontrolü { txtSckSonuc.setText(“Alanlar boş geçilemez!”); } else { double sckGiris=Double.parseDouble(txtSckGiris.getText()); double sckSonuc=0; txtSckSonuc.setText(“”); if (rdySantigratIlk.isSelected()&& cmbCikis.getSelectedItem()==”Santigrat”) { […]
2 06 2014
i= 0 s= 0 t= 0 i= 35 s= 1 t= 1 i= 70 s= 2 t= 36
2 06 2014
import java.awt.EventQueue; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JComboBox; import javax.swing.JCheckBox; import javax.swing.JPanel; import java.awt.FlowLayout; import javax.swing.UIManager; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.ButtonGroup; import java.awt.Color; import java.awt.Font; public class OtoFiyat { private […]
29 05 2014
import java.awt.EventQueue; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JRadioButton; import javax.swing.JButton; import javax.swing.JTextField; import javax.swing.JComboBox; import javax.swing.JPanel; import javax.swing.UIManager; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.ButtonGroup; import java.awt.Color; import java.awt.Font; import javax.swing.event.ChangeListener; import javax.swing.event.ChangeEvent; public class UrunSatis { private JFrame frmrnSat; private JTextField txtUrunAdi; private JTextField txtUrunFiyati; private JTextField txtUrun; private JTextField txtToplam; […]
29 05 2014
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 […]
26 05 2014
Okunan dosya örneği import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.Color; import javax.swing.JTextField; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class DosyaOku { private JFrame frame; private JTextField txtDosyaAdi; private JTextField txtIcerik; private JTextField txtAdSoyad; private JTextField […]
26 05 2014
import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import java.awt.Color; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class SayiTahminOyunu { private JFrame frmSayTahminOyunu; private JTextField txtSayi; private JTextField txtTahmin; private JTextField txtSayac; private JTextField txtMesaj; public int sayac = 0; /** * Launch the application. */ public static void […]
26 05 2014
import java.awt.EventQueue; import java.awt.TextArea; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import java.awt.Color; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JTextArea; import java.awt.Font; import javax.swing.JComboBox; import javax.swing.JCheckBox; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.event.ChangeListener; import javax.swing.event.ChangeEvent; import javax.swing.JRadioButton; import javax.swing.JPanel; import […]