Monday, March 16, 2009

Club Car Vs Yamaha Vs Ez Go

CALCULATOR (tutorial)

/ exercise calculator * * / import java.awt .*
;
import javax.swing .* ;
import java.awt.event .*;

public class CalcolatriceCompito

{JFrame f = new JFrame ("Calculator");
JLabel l1 = new JLabel ("1 operand:");
JLabel l2 = new JLabel ("2nd operand:");
JLabel l3 = new JLabel ("Result:");
JTextField f1 = new JTextField ();
JTextField f2 = new JTextField ();

JButton b1 = new JButton ("+ ");
JButton b2 = new JButton ("-");
JButton b3 = new JButton (" X ");
JButton b4 = new JButton ("/");
JButton b5 = new JButton (" clear ") ;
JButton b6 = new JButton JLabel result = new ("=");
JLabel ();
JPanel p1 = new JPanel ();
JPanel p2 = new JPanel ();
char values;

public CalcolatriceCompito () {

f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
f.setSize (400.400 )
p1.setLayout (new GridLayout (3,2));
p2.setLayout (new GridLayout (2,3));
p1.add (l1);
p1.add (f1);
p1.add (l2);
p1.add (f2);
p1.add (l3);
p1.add (result);
p2.add (b1);
p2.add (b2);
p2.add (b3 )
p2.add (b4);
p2.add (b5);
p2.add (b6);
f.add (BorderLayout.NORTH, p1);
f.add (BorderLayout.CENTER, p2);

b1.addActionListener (new Sum ());
b2.addActionListener (new Subtract ());
b3.addActionListener (new Multiply ());
b4.addActionListener ( new Division ());
b5.addActionListener (new Clear ());
b6.addActionListener (new Equal ());

f.setVisible (true);}


public class Addition implements ActionListener {public void
actionPerformed (ActionEvent event) {values \u200b\u200b
='+';

}} public class


Stealing
implements ActionListener {public void actionPerformed (ActionEvent e) {
values \u200b\u200b='-';

}} public class Multiply


implements ActionListener {public void actionPerformed (ActionEvent e) {
values \u200b\u200b= 'X';}



} public class Department implements ActionListener {public void
actionPerformed (ActionEvent e) {}
values \u200b\u200b='/';



} public class Equals implements ActionListener {public void
actionPerformed (ActionEvent event) {String text1 =
f1.getText ();
String testo2 = f2. getText ();
int t = Integer.parseInt (text1);
int t1 = Integer.parseInt (text2);
double r = 0;
if (values \u200b\u200b=='+') r = t + t1;
if (values \u200b\u200b=='-') r = t-t1;
if (value == 'X') t = r * t1; if
(r = t/t1 =='/') values;
Double.ToString String = rr (r);
risultato.setText (rr);}




} public class Clear implements ActionListener {public void actionPerformed
(ActionEvent e) {
f1.setText ("");
f2.setText ("");
risultato.setText
("");}}



public static void main (String [] args) {
CalcolatriceCompito CalcolatriceCompito f = new ();}


} ____________________________________________________________________________________

Free Image Hosting at www.ImageShack.us

QuickPost QuickPost this image to Myspace, Digg, Facebook, and others!

0 comments:

Post a Comment