import javax.swing.JFrame; import javax.swing.JTextField; import java.awt.FlowLayout; class Haromszog { public static Double szamitKerulet(double a, double b, double c) { return a + b + c; } public static Double szamitTerulet(double a, double m) { return (a * m) / 2.0; } public static Double szamitTerulet(double a, double b, double c) { double s = (a + b + c) / 2.0; return Math.sqrt(s*(s-a)*(s-b)*(s-c)); } } class Program04 extends JFrame { JTextField keruletMezo; JTextField terulet1Mezo; JTextField terulet2Mezo; Program04() { keruletMezo = new JTextField(10); terulet1Mezo = new JTextField(10); terulet2Mezo = new JTextField(10); keruletMezo.setText(Haromszog.szamitKerulet(30, 35, 40).toString()); terulet1Mezo.setText(Haromszog.szamitTerulet(30, 35).toString()); terulet2Mezo.setText(Haromszog.szamitTerulet(30, 35, 40).toString()); add(keruletMezo); add(terulet1Mezo); add(terulet2Mezo); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("Háromszög terület, kerület számító program"); setLayout(new FlowLayout()); pack(); setVisible(true); } public static void main(String[] args) { new Program04(); } }