JAVA CODE JAVA CODE: BINOMIAL TREES OPTION PRICING BINOMIALTREE CLASS PAGE 1

Size: px
Start display at page:

Download "JAVA CODE JAVA CODE: BINOMIAL TREES OPTION PRICING BINOMIALTREE CLASS PAGE 1"

Transcription

1 CODE JAVA CODE BINOMIAL TREES OPTION PRICING JAVA CODE: BINOMIAL TREES OPTION PRICING BINOMIALTREE CLASS /** * Ioannis Svigkos 2008 */ // This class corresponds to binomial tree option pricing. // Methods that calculate equity movement first are provided. // Then, methods that calculate option price in each note are // presented. Note that there is also implementation about // American options, however they need further refinement and testing import java.text.decimalformat; public class BinomialTree { // Private field members private DecimalFormat _decimalformat; private double[][] _equitymovement; // stores values of equity for each period (upper & lower) private double[][] _optionpricemovement; // stores price of call option for each period (upper & lower) private double[][] _americanputoptionpricemovement; // stores price of put option for each period private double _assetprice; private double _strikeprice; private double _riskfreerate; private double _sigma; private double _timetomaturity; private double _iteration; PAGE 1

2 private double _upperfactor; private double _lowerfactor; private double _probability; private double _deltat; // Constructor public BinomialTree ( double _assetprice, double _strikeprice, double _riskfreerate, double _sigma, double _timetomaturity, double _iteration) { // Set decimal Format _decimalformat = new DecimalFormat("#.##"); // Initialise private fields this._assetprice = _assetprice; this._strikeprice = _strikeprice; this._riskfreerate = _riskfreerate; this._sigma = _sigma; this._timetomaturity = _timetomaturity; this._iteration = _iteration; // Initilialise further parameters this._deltat = calculatedeltat(); this._upperfactor = calculateupperfactor(); this._lowerfactor = calculatelowerfactor(); this._probability = calculateprobability(); // calculate delta time public double calculatedeltat() { return _timetomaturity/_iteration; //calculate upper factor based on parameters given public double calculateupperfactor() { return Math.pow(Math.E, _sigma * Math.sqrt(_deltaT)); //calculate lower factor based on parameters given public double calculatelowerfactor() { return Math.pow(Math.E, (-_sigma) * Math.sqrt(_deltaT)); // calculate probability based on parameters given PAGE 2

3 public double calculateprobability() { return ( Math.pow(Math.E, _riskfreerate * _deltat) - _lowerfactor) / (_upperfactor - _lowerfactor); // calculate equity prices on each node public void calculateequitymovement() { // Set up matrix dimentions int _columns = ((int)_iteration) + 1; int _rows = (((int)_iteration) * 2) + 1; // Set up Matrix to hold price movements _equitymovement = new double[_rows][_columns]; // Prepare pointers for calculations int _pointer = (int)_iteration; int _pointerupper = 0; int _pointerlower = 0; int _columnpointer = 0; double _value = _assetprice; // Initialise upper pointer with row number _pointerupper = _pointer; while (true) { for (int i= _columnpointer; i < _columns; i++) { _equitymovement[_pointerupper][i] = Double.valueOf(_decimalFormat.format(_value)); i++; _pointerupper--; _columnpointer++; _value = Math.pow(_upperFactor, _columnpointer)*_assetprice; if (_pointerupper < 0) break; _columnpointer = 1; _pointerlower = _pointer + 1; _value = Math.pow(_lowerFactor, _columnpointer)*_assetprice; while (true) { PAGE 3

4 for (int i= _columnpointer; i < _columns; i++) { _equitymovement[_pointerlower][i] = Double.valueOf(_decimalFormat.format(_value)); i++; if (_pointerlower == _rows) break; _pointerlower++; _columnpointer++; _value = Math.pow(_lowerFactor, _columnpointer)*_assetprice; //priceeuropeanputoption(_equitymovement); // new BinomialTreeFrame(castArray(_equityMovement),(int)_iteration); //new BinomialTreeFrame(castArray(priceEuropeanPutOption(_strikePrice, _equitymovement)),(int) _iteration); // price European put option public double[][] priceeuropeanputoption() { calculateequitymovement(); int _rows = _equitymovement.length; int _columns = _equitymovement[1].length; _optionpricemovement = new double[_rows][_columns]; // At last column values are for (int i=0; i<_rows;i++) { if (_equitymovement[i][_columns-1]!= 0) { _optionpricemovement[i][_columns-1] = Math.max(_strikePrice-_equityMovement[i][_columns-1], 0); int pointer = _columns-2; while(true) { for (int i=0; i< _rows;i++) { if (_equitymovement[i][pointer]!= 0) { // get upper lower of next row double uppernext = _optionpricemovement[i-1][pointer+1]; double lowernext = _optionpricemovement[i+1][pointer+1]; PAGE 4

5 _optionpricemovement[i][pointer] = Math.pow(Math.E, -(_riskfreerate*_deltat)) *((_probability*uppernext)+((1- _probability)*lowernext)); if (pointer ==0) break; pointer--; //new BinomialTreeFrame(castArray(_optionPriceMovement), (int)_iteration); return _optionpricemovement; // return value located on first node (price of option) public double geteuropeanputoptionrootprice() { for (int i=0; i<_optionpricemovement.length; i++) { if (_optionpricemovement[i][0]!= 0) { return _optionpricemovement[i][0]; return 0; // calculate price of European Call Option public double[][] priceeuropeancalloption() { calculateequitymovement(); int _rows = _equitymovement.length; int _columns = _equitymovement[1].length; _optionpricemovement = new double[_rows][_columns]; // At last column values are for (int i=0; i<_rows;i++) { if (_equitymovement[i][_columns-1]!= 0) { _optionpricemovement[i][_columns-1] = Math.max(_equityMovement[i][_columns-1]-_strikePrice, 0); int pointer = _columns-2; while(true) { PAGE 5

6 for (int i=0; i< _rows;i++) { if (_equitymovement[i][pointer]!= 0) { // get upper lower of next row double uppernext = _optionpricemovement[i-1][pointer+1]; double lowernext = _optionpricemovement[i+1][pointer+1]; _optionpricemovement[i][pointer] = Math.pow(Math.E, -(_riskfreerate*_deltat)) *((_probability*uppernext)+((1- _probability)*lowernext)); if (pointer ==0) break; pointer--; //new BinomialTreeFrame(castArray(_optionPriceMovement), (int)_iteration); return _optionpricemovement; public BinomialTreeFrame getequitypricemovementpanel() { return new BinomialTreeFrame(castArray(_equityMovement), (int) _iteration); // return price held in first node (price of call option) public double geteuropeancalloptionrootprice() { for (int i=0; i<_optionpricemovement.length; i++) { if (_optionpricemovement[i][0]!= 0) { return _optionpricemovement[i][0]; return 0; // helper method that returns the number of rows // of a two dimentional array. private int getrownumber(double[][] _array) { return _array.length; // helper method that returns the number of columns // of a two dimentional array. private int getcolumnnumber(double[][] _array) { return _array[0].length; PAGE 6

7 // calculate price of American Option // NEEDS REVISION! public double[][] priceamericanputoption() { // Generate EquityPriceMovement calculateequitymovement(); // Generate EuropeanPutOptionMatrix double[][] _europeanputoptionmovement = priceeuropeanputoption(); int _rows = getrownumber(_europeanputoptionmovement); int _columns = getcolumnnumber(_europeanputoptionmovement); _americanputoptionpricemovement = new double[_rows][_columns]; // Put last two column of europeanoptionprices in new array for (int i=0; i < _rows; i++) { for (int j=0; j < _columns; j++) { _americanputoptionpricemovement[i][j] = _europeanputoptionmovement[i][j]; double _payoff = 0; double _optionprice = 0; boolean flag = false; int pointer =0; double _value = 0; // NEEDS IMPRVEMENT _americanputoptionpricemovement[3][0]=0; for (int j=_columns-2; j > 0; j--) { for (int i=0; i<_rows-1;i++) { if (_equitymovement[i][j]!= 0) { _payoff = Math.max(_strikePrice - _equitymovement[i][j], 0); _optionprice = _americanputoptionpricemovement[i][j]; if (_payoff > _optionprice) { _americanputoptionpricemovement[i][j] = _payoff; flag = true; else { _americanputoptionpricemovement[i][j] = _optionprice; if (flag) { PAGE 7

8 for (int k=j-1; k < _rows-2; k++) { _value = Math.pow(Math.E, (-_riskfreerate)*_deltat) *( (_probability*_americanputoptionpricemovement[k][j]) +((1-_probability)*_americanPutOptionPriceMovement[k+2][j])); _americanputoptionpricemovement[k+1][j-1]=_value; flag=false; _payoff = Math.max(_strikePrice - _equitymovement[((_rows-1)/2)+1][1], 0); _optionprice = _americanputoptionpricemovement[((_rows-1)/2)+1][1]; _value = Math.pow(Math.E, (-_riskfreerate)*_deltat) *( (_probability*_americanputoptionpricemovement[2][1]) +((1-_probability)*_americanPutOptionPriceMovement[4][1])); _americanputoptionpricemovement[0][0]=_value; // new BinomialTreeFrame(castArray(_optionPriceMovement), (int)_iteration); new BinomialTreeFrame(castArray(_americanPutOptionPriceMovement), (int)_iteration); return _americanputoptionpricemovement; public void recalculate(int _columns, int _rows, double[][] _array) { int pointer = _columns-2; while(true) { for (int i=0; i< _rows;i++) { if (_equitymovement[i][pointer]!= 0) { // get upper lower of next row double uppernext = _optionpricemovement[i-1][pointer+1]; double lowernext = _optionpricemovement[i+1][pointer+1]; _optionpricemovement[i][pointer] = Math.pow(Math.E, -(_riskfreerate*_deltat)) *((_probability*uppernext)+((1- _probability)*lowernext)); if (pointer ==0) break; pointer--; // Return array as an array of String values // that can be used by a JTable public String[][] castarray(double[][] _array) { int _rows = _array.length; int _columns = _array[1].length; PAGE 8

9 String[][] _sarray = new String[_rows][_columns]; for (int i=0; i < _rows; i++) { for (int j=0; j < _columns; j++) { if (_array[i][j]!= 0) { _sarray[i][j]=_array[i][j]+""; return _sarray; public static void main(string[] args) { //BinomialTree _binomialtree = new BinomialTree(7, , , , 100, 100); //_binomialtree.toprint(); // _binomialtree.toprint(); //_binomialtree.calculateeuropeanputoption(); // _binomialtree.expand(); // BinomialTreeFrame btf = new BinomialTreeFrame(_binomialTree.obtainDataModel(), 5); // _binomialtree.obtaindatamodel(); BinomialTree t = new BinomialTree(100, 100, 0.04, 0.2, 1, 400); //t.calculateequitymovement(); //t.priceeuropeanputoption(); //t.priceeuropeancalloption(); t.priceeuropeanputoption(); BINOMIALTREEFRAME[EXTENDS JFRAME] /** * Ioannis Svigkos 2008 */ // this class allows end-user to see equity price movements // and option price movements on each node in a tree representation // fashion. However, the applet provided does not consider this // option due to security settings. It is advisable that users should // run the application using java AppletViewr. import javax.swing.jframe; import javax.swing.jtable; PAGE 9

10 import javax.swing.jscrollpane; import java.awt.borderlayout; import java.text.decimalformat; public class BinomialTreeFrame extends JFrame { private JScrollPane jscrollpane1; private JTable jtable1; private double[] _columnnames; private String[] _scolumnnames; BinomialTreeFrame(String[][] _datamodel, int _iteration){ super("option Pricing: Binomial Tree"); this.setdefaultcloseoperation(jframe.exit_on_close); _columnnames = new double[_iteration + 1]; double temp1 = _iteration; DecimalFormat _dformat = new DecimalFormat("##.####"); for (int i=0; i < _iteration; i++) { if (i==0) { _columnnames[i] = 0; else { double temp = Double.valueOf(_dFormat.format(1/temp1)); _columnnames[i] = (temp) + _columnnames[i-1]; _columnnames[_columnnames.length-1] = 1; _scolumnnames = new String[_columnNames.length]; for (int i=0; i < _scolumnnames.length; i++) { _scolumnnames[i] = "" + _columnnames[i]; jtable1 = new JTable(_dataModel, _scolumnnames ); jtable1.setautoresizemode(jtable.auto_resize_off); jscrollpane1 = new JScrollPane(jTable1); jtable1.setfillsviewportheight(true); //jscrollpane1.sethorizontalscrollbar(new JScrollBar(JScrollBar.HORIZONTAL, 0, 1, 0, 255)); // this.getcontentpane(). add(jscrollpane1, BorderLayout.CENTER); // this.pack(); PAGE 10

11 this.setvisible(true); BINOMIALTREEAPPLET [GUI IMPLEMENTATION] /** * Ioannis Svigkos 2008 */ import javax.swing.jtable; import java.text.decimalformat; import javax.swing.joptionpane; public class BinomialTree_Applet extends javax.swing.japplet { // Private Field Members private double _assetprice; private double _exerciseprice; private double _volatility; private double _riskfreerate; private double _iteration; private double _timetomaturity; private double _p, _u, _d; private BinomialTree _btree; private JTable jtable1; /** Initializes the applet BinomialTree_Applet */ public void init() { try { java.awt.eventqueue.invokeandwait(new Runnable() { public void run() { initcomponents(); ); catch (Exception ex) { ex.printstacktrace(); /** This method is called from within the init() method to PAGE 11

12 * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. // <editor-fold defaultstate="collapsed" desc="generated Code"> private void initcomponents() { jpanel5 = new javax.swing.jpanel(); jtextfield5 = new javax.swing.jtextfield(); jlabel5 = new javax.swing.jlabel(); jtextfield6 = new javax.swing.jtextfield(); jtextfield7 = new javax.swing.jtextfield(); jlabel7 = new javax.swing.jlabel(); jlabel8 = new javax.swing.jlabel(); jtextfield9 = new javax.swing.jtextfield(); jlabel6 = new javax.swing.jlabel(); jtextfield8 = new javax.swing.jtextfield(); jlabel9 = new javax.swing.jlabel(); jbutton1 = new javax.swing.jbutton(); jbutton2 = new javax.swing.jbutton(); jpanel1 = new javax.swing.jpanel(); jtextfield1 = new javax.swing.jtextfield(); jlabel1 = new javax.swing.jlabel(); jtextfield2 = new javax.swing.jtextfield(); jlabel2 = new javax.swing.jlabel(); jlabel3 = new javax.swing.jlabel(); jtextfield3 = new javax.swing.jtextfield(); jlabel4 = new javax.swing.jlabel(); jtextfield4 = new javax.swing.jtextfield(); jpanel4 = new javax.swing.jpanel(); jcombobox1 = new javax.swing.jcombobox(); jradiobutton1 = new javax.swing.jradiobutton(); jradiobutton2 = new javax.swing.jradiobutton(); jlabel11 = new javax.swing.jlabel(); jtextfield11 = new javax.swing.jtextfield(); jlabel10 = new javax.swing.jlabel(); jpanel5.setborder(javax.swing.borderfactory.createtitledborder(javax.swing.borderfactory.createetchedborder(), "OUTPUT", javax.swing.border.titledborder.left, javax.swing.border.titledborder.top, new java.awt.font("arial", 1, 12), new java.awt.color(153, 153, 153))); // NOI18N jtextfield5.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jtextfield5.setforeground(new java.awt.color(102, 102, 102)); jtextfield5.sethorizontalalignment(javax.swing.jtextfield.right); jtextfield5.settooltiptext("[i.e. 100]"); jtextfield5.setborder(javax.swing.borderfactory.createetchedborder()); PAGE 12

13 jlabel5.setbackground(new java.awt.color(153, 153, 153)); jlabel5.setfont(new java.awt.font("arial", 3, 12)); jlabel5.setforeground(new java.awt.color(102, 102, 102)); jlabel5.sethorizontalalignment(javax.swing.swingconstants.center); jlabel5.settext("_ p _"); jtextfield6.seteditable(false); jtextfield6.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jtextfield6.setforeground(new java.awt.color(102, 102, 102)); jtextfield6.sethorizontalalignment(javax.swing.jtextfield.center); jtextfield6.setborder(javax.swing.borderfactory.createetchedborder()); jtextfield7.seteditable(false); jtextfield7.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jtextfield7.setforeground(new java.awt.color(102, 102, 102)); jtextfield7.sethorizontalalignment(javax.swing.jtextfield.center); jtextfield7.setborder(javax.swing.borderfactory.createetchedborder()); jlabel7.setbackground(new java.awt.color(153, 153, 153)); jlabel7.setfont(new java.awt.font("arial", 3, 12)); // NOI18N jlabel7.setforeground(new java.awt.color(102, 102, 102)); jlabel7.sethorizontalalignment(javax.swing.swingconstants.center); jlabel7.settext("_ u _"); jlabel8.setbackground(new java.awt.color(153, 153, 153)); jlabel8.setfont(new java.awt.font("arial", 3, 12)); jlabel8.setforeground(new java.awt.color(102, 102, 102)); jlabel8.sethorizontalalignment(javax.swing.swingconstants.center); jlabel8.settext("_ d _"); jtextfield9.seteditable(false); jtextfield9.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jtextfield9.setforeground(new java.awt.color(102, 102, 102)); jtextfield9.sethorizontalalignment(javax.swing.jtextfield.center); jtextfield9.setborder(javax.swing.borderfactory.createetchedborder()); jlabel6.setbackground(new java.awt.color(153, 153, 153)); jlabel6.setfont(new java.awt.font("arial", 1, 12)); jlabel6.setforeground(new java.awt.color(102, 102, 102)); jlabel6.sethorizontalalignment(javax.swing.swingconstants.center); jlabel6.settext("itteration"); jtextfield8.seteditable(false); jtextfield8.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jtextfield8.setforeground(new java.awt.color(102, 102, 102)); jtextfield8.sethorizontalalignment(javax.swing.jtextfield.right); jtextfield8.setborder(javax.swing.borderfactory.createetchedborder()); PAGE 13

14 jlabel9.setbackground(new java.awt.color(153, 153, 153)); jlabel9.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jlabel9.setforeground(new java.awt.color(102, 102, 102)); jlabel9.sethorizontalalignment(javax.swing.swingconstants.center); jlabel9.settext("option PRICE"); jbutton1.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jbutton1.setforeground(new java.awt.color(102, 102, 102)); jbutton1.settext("calculate"); jbutton1.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { jbutton1actionperformed(evt); ); jbutton2.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jbutton2.setforeground(new java.awt.color(102, 102, 102)); jbutton2.settext("display BINOMIAL TREE"); jbutton2.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { jbutton2actionperformed(evt); ); javax.swing.grouplayout jpanel5layout = new javax.swing.grouplayout(jpanel5); jpanel5.setlayout(jpanel5layout); jpanel5layout.sethorizontalgroup( jpanel5layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(jpanel5layout.createsequentialgroup().addcontainergap().addgroup(jpanel5layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(jpanel5layout.createsequentialgroup().addcomponent(jbutton1, javax.swing.grouplayout.preferred_size, 215, javax.swing.grouplayout.preferred_size).addgap(27, 27, 27).addComponent(jButton2, javax.swing.grouplayout.default_size, 217, Short.MAX_VALUE)).addGroup(jPanel5Layout.createSequentialGroup().addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jTextField5, javax.swing.grouplayout.preferred_size, 90, javax.swing.grouplayout.preferred_size).addcomponent(jlabel6, javax.swing.grouplayout.preferred_size, 86, javax.swing.grouplayout.preferred_size)).addgap(6, 6, 6).addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jLabel5, javax.swing.grouplayout.preferred_size, 84, javax.swing.grouplayout.preferred_size).addcomponent(jtextfield6, javax.swing.grouplayout.preferred_size, 82, javax.swing.grouplayout.preferred_size)) PAGE 14

15 .addgroup(jpanel5layout.createparallelgroup(javax.swing.grouplayout.alignment.leading, false).addcomponent(jlabel7, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, Short.MAX_VALUE).addComponent(jTextField7, javax.swing.grouplayout.default_size, 77, Short.MAX_VALUE)).addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addcomponent(jlabel8, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, Short.MAX_VALUE).addComponent(jTextField9, javax.swing.grouplayout.preferred_size, 74, javax.swing.grouplayout.preferred_size)).addgroup(jpanel5layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addcomponent(jtextfield8, javax.swing.grouplayout.preferred_size, 90, javax.swing.grouplayout.preferred_size).addcomponent(jlabel9)))).addcontainergap()) ); jpanel5layout.setverticalgroup( jpanel5layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(jpanel5layout.createsequentialgroup().addcontainergap().addgroup(jpanel5layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(jpanel5layout.createsequentialgroup().addcomponent(jlabel6).addcomponent(jtextfield5, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size)).addgroup(jpanel5layout.createsequentialgroup().addgroup(jpanel5layout.createparallelgroup(javax.swing.grouplayout.alignment.baseline).addcomponent(jlabel5).addcomponent(jlabel8).addcomponent(jlabel7).addcomponent(jlabel9)).addgroup(jpanel5layout.createparallelgroup(javax.swing.grouplayout.alignment.baseline).addcomponent(jtextfield6, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size).addcomponent(jtextfield9, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size).addcomponent(jtextfield7, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size).addcomponent(jtextfield8, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size)))).addgap(17, 17, 17).addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jButton2, javax.swing.grouplayout.default_size, 23, Short.MAX_VALUE).addComponent(jButton1, javax.swing.grouplayout.default_size, 24, Short.MAX_VALUE)) PAGE 15

16 );.addcontainergap()) jpanel1.setborder(javax.swing.borderfactory.createtitledborder(javax.swing.borderfactory.createetchedborder(), "PARAMETERS", javax.swing.border.titledborder.left, javax.swing.border.titledborder.top, new java.awt.font("arial", 1, 12), new java.awt.color(153, 153, 153))); // NOI18N jtextfield1.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jtextfield1.setforeground(new java.awt.color(102, 102, 102)); jtextfield1.sethorizontalalignment(javax.swing.jtextfield.right); jtextfield1.settooltiptext("[i.e ]"); jtextfield1.setborder(javax.swing.borderfactory.createetchedborder()); jlabel1.setbackground(new java.awt.color(153, 153, 153)); jlabel1.setfont(new java.awt.font("arial", 1, 12)); jlabel1.setforeground(new java.awt.color(102, 102, 102)); jlabel1.sethorizontalalignment(javax.swing.swingconstants.center); jlabel1.settext("asset PRICE"); jtextfield2.setfont(new java.awt.font("arial", 1, 12)); jtextfield2.setforeground(new java.awt.color(102, 102, 102)); jtextfield2.sethorizontalalignment(javax.swing.jtextfield.right); jtextfield2.settooltiptext("[i.e ]"); jtextfield2.setborder(javax.swing.borderfactory.createetchedborder()); jlabel2.setbackground(new java.awt.color(153, 153, 153)); jlabel2.setfont(new java.awt.font("arial", 1, 12)); jlabel2.setforeground(new java.awt.color(102, 102, 102)); jlabel2.sethorizontalalignment(javax.swing.swingconstants.center); jlabel2.settext("exercise PRICE"); jlabel3.setbackground(new java.awt.color(153, 153, 153)); jlabel3.setfont(new java.awt.font("arial", 1, 12)); jlabel3.setforeground(new java.awt.color(102, 102, 102)); jlabel3.sethorizontalalignment(javax.swing.swingconstants.center); jlabel3.settext("risk FREE RATE"); jtextfield3.setfont(new java.awt.font("arial", 1, 12)); jtextfield3.setforeground(new java.awt.color(102, 102, 102)); jtextfield3.sethorizontalalignment(javax.swing.jtextfield.right); jtextfield3.setborder(javax.swing.borderfactory.createetchedborder()); jlabel4.setbackground(new java.awt.color(153, 153, 153)); jlabel4.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jlabel4.setforeground(new java.awt.color(102, 102, 102)); jlabel4.sethorizontalalignment(javax.swing.swingconstants.center); jlabel4.settext("volatility"); PAGE 16

17 jtextfield4.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jtextfield4.setforeground(new java.awt.color(102, 102, 102)); jtextfield4.sethorizontalalignment(javax.swing.jtextfield.right); jtextfield4.setborder(javax.swing.borderfactory.createetchedborder()); javax.swing.grouplayout jpanel1layout = new javax.swing.grouplayout(jpanel1); jpanel1.setlayout(jpanel1layout); jpanel1layout.sethorizontalgroup( jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(jpanel1layout.createsequentialgroup().addcontainergap().addgroup(jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.trailing).addgroup(javax.swing.grouplayout.alignment.leading, jpanel1layout.createsequentialgroup().addgroup(jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.trailing).addcomponent(jtextfield1, javax.swing.grouplayout.alignment.leading, javax.swing.grouplayout.default_size, 93, Short.MAX_VALUE).addComponent(jLabel1, javax.swing.grouplayout.alignment.leading, javax.swing.grouplayout.default_size, 93, Short.MAX_VALUE)).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jTextField2, javax.swing.grouplayout.alignment.leading, javax.swing.grouplayout.default_size, 93, Short.MAX_VALUE).addComponent(jLabel2, javax.swing.grouplayout.alignment.leading, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, Short.MAX_VALUE))).addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpanel1layout.createsequentialgroup().addgroup(jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.trailing).addcomponent(jtextfield3, javax.swing.grouplayout.alignment.leading, javax.swing.grouplayout.default_size, 93, Short.MAX_VALUE).addComponent(jLabel3, javax.swing.grouplayout.alignment.leading, javax.swing.grouplayout.default_size, 93, Short.MAX_VALUE)).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jTextField4, javax.swing.grouplayout.alignment.leading, javax.swing.grouplayout.default_size, 93, Short.MAX_VALUE).addComponent(jLabel4, javax.swing.grouplayout.alignment.leading, javax.swing.grouplayout.default_size, 93, Short.MAX_VALUE)))).addGap(28, 28, 28)) ); jpanel1layout.setverticalgroup( jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(jpanel1layout.createsequentialgroup().addcontainergap().addgroup(jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(jpanel1layout.createsequentialgroup().addcomponent(jlabel1).addcomponent(jtextfield1, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size)) PAGE 17

18 .addgroup(jpanel1layout.createsequentialgroup().addcomponent(jlabel2).addcomponent(jtextfield2, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size))).addgroup(jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(jpanel1layout.createsequentialgroup().addcomponent(jlabel3).addcomponent(jtextfield3, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size)).addgroup(jpanel1layout.createsequentialgroup().addcomponent(jlabel4).addcomponent(jtextfield4, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size))).addcontainergap(22, Short.MAX_VALUE)) ); jpanel4.setborder(javax.swing.borderfactory.createtitledborder(javax.swing.borderfactory.createetchedborder(), "OPTION TYPE", javax.swing.border.titledborder.left, javax.swing.border.titledborder.top, new java.awt.font("arial", 1, 12), new java.awt.color(153, 153, 153))); // NOI18N jcombobox1.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jcombobox1.setforeground(new java.awt.color(153, 153, 153)); jcombobox1.setmodel(new javax.swing.defaultcomboboxmodel(new String[] { "European")); jcombobox1.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { jcombobox1actionperformed(evt); ); jradiobutton1.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jradiobutton1.setforeground(new java.awt.color(102, 102, 102)); jradiobutton1.setselected(true); jradiobutton1.settext("call OPTION"); jradiobutton1.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { jradiobutton1actionperformed(evt); ); jradiobutton2.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jradiobutton2.setforeground(new java.awt.color(102, 102, 102)); jradiobutton2.settext("put OPTION"); jradiobutton2.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { PAGE 18

19 ); jradiobutton2actionperformed(evt); jlabel11.setbackground(new java.awt.color(153, 153, 153)); jlabel11.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jlabel11.setforeground(new java.awt.color(102, 102, 102)); jlabel11.sethorizontalalignment(javax.swing.swingconstants.center); jlabel11.settext("time TO MATURITY"); jtextfield11.setfont(new java.awt.font("arial", 1, 12)); // NOI18N jtextfield11.setforeground(new java.awt.color(102, 102, 102)); jtextfield11.sethorizontalalignment(javax.swing.jtextfield.right); jtextfield11.settooltiptext("[i.e for 3 months]"); jtextfield11.setborder(javax.swing.borderfactory.createetchedborder()); javax.swing.grouplayout jpanel4layout = new javax.swing.grouplayout(jpanel4); jpanel4.setlayout(jpanel4layout); jpanel4layout.sethorizontalgroup( jpanel4layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(javax.swing.grouplayout.alignment.trailing, jpanel4layout.createsequentialgroup().addcontainergap().addgroup(jpanel4layout.createparallelgroup(javax.swing.grouplayout.alignment.trailing).addgroup(jpanel4layout.createsequentialgroup().addcomponent(jradiobutton1).addpreferredgap(javax.swing.layoutstyle.componentplacement.related, 13, Short.MAX_VALUE).addComponent(jRadioButton2)).addComponent(jComboBox1, javax.swing.grouplayout.alignment.leading, 0, 211, Short.MAX_VALUE).addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpanel4layout.createsequentialgroup().addcomponent(jlabel11).addgap(18, 18, 18).addComponent(jTextField11, javax.swing.grouplayout.default_size, 86, Short.MAX_VALUE))).addContainerGap()) ); jpanel4layout.setverticalgroup( jpanel4layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(jpanel4layout.createsequentialgroup().addcontainergap().addcomponent(jcombobox1, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size).addgap(7, 7, 7).addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jRadioButton1).addComponent(jRadioButton2)).addGap(18, 18, 18).addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel11) PAGE 19

20 .addcomponent(jtextfield11, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size)).addcontainergap(20, Short.MAX_VALUE)) ); jlabel10.setbackground(new java.awt.color(153, 153, 153)); jlabel10.setfont(new java.awt.font("arial", 1, 12)); jlabel10.setforeground(new java.awt.color(102, 102, 102)); jlabel10.sethorizontalalignment(javax.swing.swingconstants.center); jlabel10.settext("developed by Ioannis Svigkos 2008"); javax.swing.grouplayout layout = new javax.swing.grouplayout(getcontentpane()); getcontentpane().setlayout(layout); layout.sethorizontalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(layout.createsequentialgroup().addcontainergap().addgroup(layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addcomponent(jlabel10, javax.swing.grouplayout.default_size, 491, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(jPanel1, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size).addcomponent(jpanel4, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, Short.MAX_VALUE)).addComponent(jPanel5, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, Short.MAX_VALUE)).addContainerGap()) ); layout.setverticalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addgroup(layout.createsequentialgroup().addgroup(layout.createparallelgroup(javax.swing.grouplayout.alignment.leading, false).addcomponent(jpanel4, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, Short.MAX_VALUE).addComponent(jPanel1, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, Short.MAX_VALUE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jPanel5, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size).addgap(25, 25, 25).addComponent(jLabel10).addContainerGap(13, Short.MAX_VALUE)) ); // </editor-fold> private void jbutton1actionperformed(java.awt.event.actionevent evt) { PAGE 20

21 try { _assetprice = Double.parseDouble(jTextField1.getText()); _exerciseprice = Double.parseDouble(jTextField2.getText()); _riskfreerate = Double.parseDouble(jTextField3.getText()); _volatility = Double.parseDouble(jTextField4.getText()); _iteration = Double.parseDouble(jTextField5.getText()); _timetomaturity = Double.parseDouble(jTextField11.getText()); catch(numberformatexception e) { JOptionPane.showMessageDialog(this, "Please check values entered!", "Error Message", JOptionPane.ERROR_MESSAGE); _btree = new BinomialTree( _assetprice, _exerciseprice, _riskfreerate, _volatility, _timetomaturity, _iteration); this._u = roundtoeightdecimals(_btree.calculateupperfactor()); // roundtoeightdecimals*/(math.pow(math.e, _volatility * Math.sqrt(1/(_iteration-1)))); this._d = roundtoeightdecimals(_btree.calculatelowerfactor()); //*roundtoeightdecimals*/(math.pow(math.e, - _volatility * Math.sqrt((1/_iteration-1)))); this._p = roundtoeightdecimals(_btree.calculateprobability()); //*roundtoeightdecimals*/((math.pow(math.e, _riskfreerate* ((_iteration-1)))-_d) / (_u - _d)); jtextfield6.settext(string.valueof(_p)); jtextfield7.settext(string.valueof(_u)); jtextfield9.settext(string.valueof(_d)); if (jcombobox1.getselecteditem().equals("european")) { if (jradiobutton1.isselected() ) { _btree.priceeuropeancalloption(); System.out.println(_btree.getEuropeanCallOptionRootPrice()); jtextfield8.settext(string.valueof(roundtoeightdecimals(_btree.geteuropeancalloptionrootprice()))); // _btree.expand(); else if (jradiobutton2.isselected()) { _btree.priceeuropeanputoption(); jtextfield8.settext(string.valueof(roundtoeightdecimals(_btree.geteuropeanputoptionrootprice()))); // _btree.expand(); public double roundtoeightdecimals(double _double) { DecimalFormat toeightdecimalform = new DecimalFormat("#.########"); return Double.valueOf(toEightDecimalForm.format(_double)); PAGE 21

22 private void jbutton2actionperformed(java.awt.event.actionevent evt) { // TODO add your handling code here: JOptionPane.showMessageDialog(this, "Browser's Security Features Restrict this Action!", "Information Message", JOptionPane.INFORMATION_MESSAGE); private void jcombobox1actionperformed(java.awt.event.actionevent evt) { // TODO add your handling code here: private void jradiobutton1actionperformed(java.awt.event.actionevent evt) { jradiobutton2.setselected(false); if (!jradiobutton1.isselected()) { jradiobutton1.setselected(true); private void jradiobutton2actionperformed(java.awt.event.actionevent evt) { jradiobutton1.setselected(false); if (!jradiobutton2.isselected()) { jradiobutton2.setselected(true); // Variables declaration - do not modify private javax.swing.jbutton jbutton1; private javax.swing.jbutton jbutton2; private javax.swing.jcombobox jcombobox1; private javax.swing.jlabel jlabel1; private javax.swing.jlabel jlabel10; private javax.swing.jlabel jlabel11; private javax.swing.jlabel jlabel2; private javax.swing.jlabel jlabel3; private javax.swing.jlabel jlabel4; private javax.swing.jlabel jlabel5; private javax.swing.jlabel jlabel6; private javax.swing.jlabel jlabel7; private javax.swing.jlabel jlabel8; private javax.swing.jlabel jlabel9; private javax.swing.jpanel jpanel1; private javax.swing.jpanel jpanel4; private javax.swing.jpanel jpanel5; private javax.swing.jradiobutton jradiobutton1; private javax.swing.jradiobutton jradiobutton2; private javax.swing.jtextfield jtextfield1; PAGE 22

23 private javax.swing.jtextfield jtextfield11; private javax.swing.jtextfield jtextfield2; private javax.swing.jtextfield jtextfield3; private javax.swing.jtextfield jtextfield4; private javax.swing.jtextfield jtextfield5; private javax.swing.jtextfield jtextfield6; private javax.swing.jtextfield jtextfield7; private javax.swing.jtextfield jtextfield8; private javax.swing.jtextfield jtextfield9; // End of variables declaration PAGE 23

Java Programming Summer 2008 LAB. Thursday 8/21/2008

Java Programming Summer 2008 LAB. Thursday 8/21/2008 LAB Thursday 8/21/2008 Design and implement the program that contains a timer. When the program starts, the timer shows 00:00:00. When we click the Start button, the timer starts. When we click the Stop

More information

* To change this license header, choose License Headers in Project Properties.

* To change this license header, choose License Headers in Project Properties. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools Templates * and open the template in the editor. package tugasumbyjava; /**

More information

* To change this license header, choose License Headers in Project Properties.

* To change this license header, choose License Headers in Project Properties. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools Templates * and open the template in the editor. */ package calci; /** * *

More information

Answer on question #61311, Programming & Computer Science / Java

Answer on question #61311, Programming & Computer Science / Java Answer on question #61311, Programming & Computer Science / Java JSP JSF for completion Once the user starts the thread by clicking a button, the program must choose a random image out of an image array,

More information

Appendix I: Software Coding

Appendix I: Software Coding References [1] Ceylon Electricity Board, Statistical Digest 2015, pp 2 [2] Roy Billinton and Ronald N. Allan, Reliability Evaluation of Engineering Systems: Concepts and Techniques, Springer (first published

More information

/** Creates new form NewJFrame */ public NewJFrame() { initcomponents(); initblogsearch(); //initializes Index List box }

/** Creates new form NewJFrame */ public NewJFrame() { initcomponents(); initblogsearch(); //initializes Index List box } /* * To change this template, choose Tools Templates * and open the template in the editor. */ /* * NewJFrame.java * * Created on Apr 17, 2011, 1:13:13 PM */ /** * * @author Kelli */ import java.io.*;

More information

Travel Agency. Khateeb Engineering Classes. Mini Project. Khateeb Engineering Classes: / Technology to be used

Travel Agency. Khateeb Engineering Classes. Mini Project. Khateeb Engineering Classes: / Technology to be used Khateeb Engineering Classes Mini Project Travel Agency Technology to be used Front end :Java Swings Back End: PHP Myadmin Requirements : 1) Jdk ( version 1.6 or upwards) 2) Netbeans (Version 6.0 or upwards)

More information

jlabel14 = new javax.swing.jlabel(); jlabel15 = new javax.swing.jlabel(); jlabel16 = new javax.swing.jlabel(); jlabel17 = new javax.swing.

jlabel14 = new javax.swing.jlabel(); jlabel15 = new javax.swing.jlabel(); jlabel16 = new javax.swing.jlabel(); jlabel17 = new javax.swing. 188 APPENDIX 1 { jinternalframe1 = new javax.swing.jinternalframe(); jlabel1 = new javax.swing.jlabel(); jlabel2 = new javax.swing.jlabel(); jlabel3 = new javax.swing.jlabel(); jlabel4 = new javax.swing.jlabel();

More information

CHAPTER 8 INFERENCE. The concept of Inference would be explained in the following chapter, as the CTBN

CHAPTER 8 INFERENCE. The concept of Inference would be explained in the following chapter, as the CTBN CHAPTER 8 INFERENCE The concept of Inference would be explained in the following chapter, as the CTBN framework has already been detailed on. The chapter begins by answering the most asked queries and

More information

I.1 Introduction Matisse GUI designer I.2 GroupLayout Basics Sequential and Parallel Arrangements sequential horizontal orientation

I.1 Introduction Matisse GUI designer I.2 GroupLayout Basics Sequential and Parallel Arrangements sequential horizontal orientation I GroupLayout I.1 Introduction Java SE 6 includes a powerful layout manager called GroupLayout, which is the default layout manager in the NetBeans IDE (www.netbeans.org). In this appendix, we overview

More information

Role-Coll Role Based Collaboration Software

Role-Coll Role Based Collaboration Software Department of Computer Science University of Nevada, Reno Role-Coll Role Based Collaboration Software CS 425 12/12/2006 Software Team: Harold De Armas, Erik Hanchett, Raymond Lee, Zack Norcross Business

More information

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split DAFTAR LAMPIRAN Source Code Java Aplikasi Keyword to Image Renamer Split Source Code Menu Utama package spin_text; import java.awt.color; import java.awt.event.actionevent; import java.awt.event.actionlistener;

More information

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer

More information

privateint m, n, smithitemcount, raitaitemcount;

privateint m, n, smithitemcount, raitaitemcount; LISTING PROGRAM /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools Templates * and open the template in the editor. */ package

More information

Lampiran A. SOURCE CODE PROGRAM

Lampiran A. SOURCE CODE PROGRAM A-1 Lampiran A. SOURCE CODE PROGRAM Frame Utama package FrameDesign; import ArithmeticSkripsi.ArithmeticCompress; import ArithmeticSkripsi.ArithmeticDecompress; import Deflate.DeflateContoh; import java.io.file;

More information

INSTITUTO POLITÉCNICO NACIONAL ESCUELA SUPERIOR DE CÓMPUTO

INSTITUTO POLITÉCNICO NACIONAL ESCUELA SUPERIOR DE CÓMPUTO INSTITUTO POLITÉCNICO NACIONAL ESCUELA SUPERIOR DE CÓMPUTO Cryptography Practice 1,2,3 By: Raúl Emmanuel Delgado Díaz de León Professor: M. en C. NIDIA ASUNCIÓN CORTEZ DUARTE February2015 Index Contenido

More information

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords Goals By the end of this lesson, you should: Lecture 7 More GUI programming 1. Be able to write Java s with JTextField, JList, JCheckBox and JRadioButton components 2. Be able to implement a ButtonGroup

More information

CSCI 201L Midterm Written Summer % of course grade

CSCI 201L Midterm Written Summer % of course grade CSCI 201L Summer 2016 10% of course grade 1. Abstract Classes and Interfaces Give two differences between an interface and an abstract class in which all of the methods are abstract. (0.5% + 0.5%) 2. Serialization

More information

We have several alternatives now, which we need to address. Here is a list of them: 1. How to get HTML interpreted correctly.

We have several alternatives now, which we need to address. Here is a list of them: 1. How to get HTML interpreted correctly. Applets in Java using NetBeans as an IDE Creating an Interactive Browser using JEditorPane (Part 3) C.W. David Department of Chemistry University of Connecticut Storrs, CT 06269-3060 Carl.David@uconn.edu

More information

/* * MoraDrill.java * Version last updated 6 April 2010 * Written by John K. Estell * Created on November 30, 2008, 10:22 PM */

/* * MoraDrill.java * Version last updated 6 April 2010 * Written by John K. Estell * Created on November 30, 2008, 10:22 PM */ /* * MoraDrill.java * Version 2.1.0 - last updated 6 April 2010 * Written by John K. Estell * Created on November 30, 2008, 10:22 PM */ package MoraDrill; import java.io.inputstream; import java.awt.*;

More information

Project Helpine Report BANQUET HALL BOOKING

Project Helpine Report BANQUET HALL BOOKING Project Helpine Report BANQUET HALL BOOKING - 1 - BANQUET HALL BOOKING TABLE OF CONTENT Contents Page No. Acknowledgment 3 Declaration 4 1. Introduction & Objectives of the Project 1.1 Introduction 7 1.2

More information

CSCI 201L Midterm Written SOLUTION Summer % of course grade

CSCI 201L Midterm Written SOLUTION Summer % of course grade CSCI 201L SOLUTION Summer 2016 10% of course grade 1. Abstract Classes and Interfaces Give two differences between an interface and an abstract class in which all of the methods are abstract. (0.5% + 0.5%)

More information

COMP16121 Sample Code Lecture 1

COMP16121 Sample Code Lecture 1 COMP16121 Sample Code Lecture 1 Sean Bechhofer, University of Manchester, Manchester, UK sean.bechhofer@manchester.ac.uk 1 SimpleFrame 1 import javax.swing.jframe; 2 3 public class SimpleFrame { 4 5 /*

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate

More information

!"# $ %&# %####' #&() % # # # #&* # ## +, # -

!# $ %&# %####' #&() % # # # #&* # ## +, # - By Pep Jorge @joseplluisjorge Steema Software July 213!"# $ %&# %####' #&() % # # # #&* # ## +, # -. / " - $- * 11 1 1$ 2 11 1 3 4 / $ 5 5,+67 +68$ Copyright 213 Steema Software SL. Copyright Information.

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan

More information

SampleApp.java. Page 1

SampleApp.java. Page 1 SampleApp.java 1 package msoe.se2030.sequence; 2 3 /** 4 * This app creates a UI and processes data 5 * @author hornick 6 */ 7 public class SampleApp { 8 private UserInterface ui; // the UI for this program

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod If the

More information

The class definition is not a program by itself. It can be used by other programs in order to create objects and use them.

The class definition is not a program by itself. It can be used by other programs in order to create objects and use them. Data Classes and Object-Oriented Programming Data classes can be motivated by the need to create data structures that have grouped together a number of variables of simpler type (ints, Strings, arrays)

More information

APPENDIX. public void cekroot() { System.out.println("nilai root : "+root.data); }

APPENDIX. public void cekroot() { System.out.println(nilai root : +root.data); } APPENDIX CLASS NODE AS TREE OBJECT public class Node public int data; public Node left; public Node right; public Node parent; public Node(int i) data=i; PROCEDURE BUILDING TREE public class Tree public

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CMPE212, FALL TERM, 2012 FINAL EXAMINATION 18 December 2012, 2pm Instructor: Alan McLeod If the instructor is unavailable

More information

AnimatedImage.java. Page 1

AnimatedImage.java. Page 1 1 import javax.swing.japplet; 2 import javax.swing.jbutton; 3 import javax.swing.jpanel; 4 import javax.swing.jcombobox; 5 import javax.swing.jlabel; 6 import javax.swing.imageicon; 7 import javax.swing.swingutilities;

More information

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau List of Slides 1 Title 2 Chapter 13: Graphical user interfaces 3 Chapter aims 4 Section 2: Example:Hello world with a GUI 5 Aim 6 Hello world with a GUI 7 Hello world with a GUI 8 Package: java.awt and

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod

More information

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Systems Programming Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Leganés, 21st of March, 2014. Duration: 75 min. Full

More information

TECHNICAL DOCUMENTATION

TECHNICAL DOCUMENTATION TECHNICAL DOCUMENTATION UNDERSTANDING THE JAVA/XML CODE BINDING IN OPENBRAVO POS AND LITTLE EDITING SPONSORED BY: IT-KAMER COMPANY LTD CEO: Dr.-Ing. Stanley Mungwe SONDI Mikael Steve jobs project Cameroon

More information

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod

More information

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but

More information

Graphical User Interface

Graphical User Interface Lecture 10 Graphical User Interface An introduction Sahand Sadjadee sahand.sadjadee@liu.se Programming Fundamentals 725G61 http://www.ida.liu.se/~725g61/ Department of Computer and Information Science

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2008 FINAL EXAMINATION 7pm to 10pm, 17 DECEMBER 2008, Grant Hall Instructor: Alan McLeod

More information

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008 Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object

More information

Swing - JTextField. Adding a text field to the main window (with tooltips and all)

Swing - JTextField. Adding a text field to the main window (with tooltips and all) Swing - JTextField Adding a text field to the main window (with tooltips and all) Prerequisites - before this lecture You should have seen: The lecture on JFrame The lecture on JButton Including having

More information

Client-side GUI. A simple Swing-gui for searching for proudcts

Client-side GUI. A simple Swing-gui for searching for proudcts Client-side GUI A simple Swing-gui for searching for proudcts Working from a sketch to a rough GUI We make a list of the features / requirements We ll then start with a sketch of how a GUI for searching

More information

CSIS 10A Assignment 7 SOLUTIONS

CSIS 10A Assignment 7 SOLUTIONS CSIS 10A Assignment 7 SOLUTIONS Read: Chapter 7 Choose and complete any 10 points from the problems below, which are all included in the download file on the website. Use BlueJ to complete the assignment,

More information

PART 23. Java GUI Advanced JList Component. more items.

PART 23. Java GUI Advanced JList Component. more items. PART 23 Java GUI Advanced 23.1 JList Component JList is a component that displays a list of objects. It allows the user to select one or more items. import java.awt.color; import java.awt.eventqueue; import

More information

AppBisect > PrBisect > class Functie. AppBisect > PrBisect > class Punct. public class Functie { double x(double t) { return t;

AppBisect > PrBisect > class Functie. AppBisect > PrBisect > class Punct. public class Functie { double x(double t) { return t; 1 AppBisect > PrBisect > class Punct public class Punct { double x,y; public Punct(double x, double y) { this.x = x; this.y = y; public void setx(double x) { this.x = x; public double getx() { return x;

More information

This is the java code for generating coördinates of molecules numerically using the CDNT framework with real-time input and diagramatic output.

This is the java code for generating coördinates of molecules numerically using the CDNT framework with real-time input and diagramatic output. This is the java code for generating coördinates of molecules numerically using the DNT framework with real-time input and diagramatic output. * cdnt.java * * reated on January 25, 2006, 8:38 AM * System

More information

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling Handout 12 CS603 Object-Oriented Programming Fall 15 Page 1 of 12 Handout 14 Graphical User Interface (GUI) with Swing, Event Handling The Swing library (javax.swing.*) Contains classes that implement

More information

// autor igre Ivan Programerska sekcija package mine;

// autor igre Ivan Programerska sekcija package mine; // autor igre Ivan Bauk @ Programerska sekcija package mine; import java.awt.color; import java.awt.flowlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener;

More information

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University 9/5/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today: Arrays (D and D) Methods Program structure Fields vs local variables Next time: Program structure continued: Classes

More information

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver Building a GUI in Java with Swing CITS1001 extension notes Rachel Cardell-Oliver Lecture Outline 1. Swing components 2. Building a GUI 3. Animating the GUI 2 Swing A collection of classes of GUI components

More information

COSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan

COSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan COSC 123 Computer Creativity Graphics and Events Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Key Points 1) Draw shapes, text in various fonts, and colors. 2) Build

More information

Constructing an Index Fund Using Interior Point Primal Dual Method

Constructing an Index Fund Using Interior Point Primal Dual Method MASTER THESIS IN APPLIED MATHEMATICS MMA891 Degree Project in Mathematics Constructing an Index Fund Using Interior Point Primal Dual Method by Sampid Marius Galabe & Kamta Celestin Masterarbete i matematik/tillämpad

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Solution HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod If the

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2010 FINAL EXAMINATION 11 DECEMBER 2010, 9am SOLUTION HAND IN Answers Are Recorded on Question Paper Instructor: Alan McLeod If the instructor

More information

LAMPIRAN PERANGKAT LUNAK

LAMPIRAN PERANGKAT LUNAK LAMPIRAN PERANGKAT LUNAK package com.fr.core; import com.googlecode.javacv.cpp.opencv_core; import com.googlecode.javacv.cpp.opencv_imgproc; import com.googlecode.javacv.cpp.opencv_objdetect; import java.awt.image.bufferedimage;

More information

CMP 326 Final Spring There is a blank page at the end of the exam if you need more room to answer a question.

CMP 326 Final Spring There is a blank page at the end of the exam if you need more room to answer a question. CMP 326 Final Spring 2014 Name: There is a blank page at the end of the exam if you need more room to answer a question. 1) (10 pts) Fill in the blanks to specify the missing keywords or definitions. public

More information

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13 CONTENTS Chapter 1 Getting Started with Java SE 6 1 Introduction of Java SE 6... 3 Desktop Improvements... 3 Core Improvements... 4 Getting and Installing Java... 5 A Simple Java Program... 10 Compiling

More information

CSCI 201L Midterm Written Fall % of course grade

CSCI 201L Midterm Written Fall % of course grade CSCI 201L Midterm Written Fall 2015 10% of course grade 1. Inheritance Answer the following questions about inheritance. a. Does Java allow overloading, overriding, and redefining of methods? (0.5%) b.

More information

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI CBOP3203 Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI components like button, text input, scroll bar and others.

More information

CSCI 201L Midterm Written SOLUTION Fall % of course grade

CSCI 201L Midterm Written SOLUTION Fall % of course grade CSCI 201L Midterm Written SOLUTION Fall 2015 10% of course grade 1. Inheritance Answer the following questions about inheritance. a. Does Java allow overloading, overriding, and redefining of methods?

More information

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners GUI (Graphic User Interface) Programming Part 2 (Chapter 8) Chapter Goals To understand the Java event model To install action and mouse event listeners To accept input from buttons, text fields, and the

More information

HomeWork 3. In this homework, an ArchJava application that allows one to query one s scores in a networked environment is presented.

HomeWork 3. In this homework, an ArchJava application that allows one to query one s scores in a networked environment is presented. HomeWork 3 In this homework, an ArchJava application that allows one to query one s scores in a networked environment is presented. [1] Acme Description The architecture that has been implemented using

More information

グラフを表すデータ構造 JAVA での実装

グラフを表すデータ構造 JAVA での実装 グラフを表すデータ構造 JAVA での実装 グラフの構造を記述するクラス パッケージgraphLib graphlib.graph グラフ全体 graphlib.vertex 頂点 頂点を始点とする弧 頂点を2 次元面に表示するための座標 graphlib.arc 弧の始点と終点 クラスの関係 グラフ 弧一覧 弧 弧 頂点 弧 頂点一覧 頂点 頂点 写像 + 頂点 写像 頂点 写像 δ + GRAPH

More information

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Rui Moreira Some useful links: http://java.sun.com/docs/books/tutorial/uiswing/toc.html http://www.unix.org.ua/orelly/java-ent/jfc/

More information

Graphical User Interfaces in Java - SWING

Graphical User Interfaces in Java - SWING Graphical User Interfaces in Java - SWING Graphical User Interfaces (GUI) Each graphical component that the user can see on the screen corresponds to an object of a class Component: Window Button Menu...

More information

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

JRadioButton account_type_radio_button2 = new JRadioButton(Current); ButtonGroup account_type_button_group = new ButtonGroup(); Q)Write a program to design an interface containing fields User ID, Password and Account type, and buttons login, cancel, edit by mixing border layout and flow layout. Add events handling to the button

More information

Our first program is a simple calculator, which will carry out the arithmetic operations of adding, subtracting, multiplying and dividing numbers.

Our first program is a simple calculator, which will carry out the arithmetic operations of adding, subtracting, multiplying and dividing numbers. Chapter 2: Calculations 29 2 Calculations Most computer programs need to carry out calculations, for example: with money, quantities of materials, or dates and times. In this chapter, we will examine how

More information

Swing - JLabel. Adding a text (and HTML) labels to a GUI

Swing - JLabel. Adding a text (and HTML) labels to a GUI Swing - JLabel Adding a text (and HTML) labels to a GUI Prerequisites - before this lecture You should have seen: The lecture on JFrame The lecture on JButton The lectuer on JTextField Including having

More information

MIT AITI Swing Event Model Lecture 17

MIT AITI Swing Event Model Lecture 17 MIT AITI 2004 Swing Event Model Lecture 17 The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the user. But how do GUIs interact with users? How do applications

More information

/* Write a Program implementing GUI based Calculator using Swing */

/* Write a Program implementing GUI based Calculator using Swing */ /* Write a Program implementing GUI based Calculator using Swing */ import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.*; public class Calculator extends JFrame

More information

Part I: Learn Common Graphics Components

Part I: Learn Common Graphics Components OOP GUI Components and Event Handling Page 1 Objectives 1. Practice creating and using graphical components. 2. Practice adding Event Listeners to handle the events and do something. 3. Learn how to connect

More information

PART1: Choose the correct answer and write it on the answer sheet:

PART1: Choose the correct answer and write it on the answer sheet: PART1: Choose the correct answer and write it on the answer sheet: (15 marks 20 minutes) 1. Which of the following is included in Java SDK? a. Java interpreter c. Java disassembler b. Java debugger d.

More information

Java Swing Introduction

Java Swing Introduction Course Name: Advanced Java Lecture 18 Topics to be covered Java Swing Introduction What is Java Swing? Part of the Java Foundation Classes (JFC) Provides a rich set of GUI components Used to create a Java

More information

Dr. Hikmat A. M. AbdelJaber

Dr. Hikmat A. M. AbdelJaber Dr. Hikmat A. M. AbdelJaber JWindow: is a window without a title bar or move controls. The program can move and resize it, but the user cannot. It has no border at all. It optionally has a parent JFrame.

More information

Control Statements: Part Pearson Education, Inc. All rights reserved.

Control Statements: Part Pearson Education, Inc. All rights reserved. 1 5 Control Statements: Part 2 5.2 Essentials of Counter-Controlled Repetition 2 Counter-controlled repetition requires: Control variable (loop counter) Initial value of the control variable Increment/decrement

More information

Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012)

Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012) Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012) Medialogy, 4 th Semester, Aalborg Thursday 23 August 2012, 09.00 12.00 Instructions

More information

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod If

More information

Section Basic graphics

Section Basic graphics Chapter 16 - GUI Section 16.1 - Basic graphics Java supports a set of objects for developing graphical applications. A graphical application is a program that displays drawings and other graphical objects.

More information

Swing Programming Example Number 2

Swing Programming Example Number 2 1 Swing Programming Example Number 2 Problem Statement (Part 1 and 2 (H/w- assignment) 2 Demonstrate the use of swing Label, TextField, RadioButton, CheckBox, Listbox,Combo Box, Toggle button,image Icon

More information

PART 22. Java GUI Library SWT GUI Library SWING GUI Library Swing First Program

PART 22. Java GUI Library SWT GUI Library SWING GUI Library Swing First Program PART 22 Java GUI Library 22.1 SWT GUI Library There is also another GUI library for the Java programming language. It is called SWT (The Standard widget toolkit). The SWT library was initially developed

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2012 FINAL EXAMINATION 9am to 12pm, 26 APRIL 2012 Instructor: Alan McLeod If the instructor is

More information

COMP 1006/1406 Assignment 1 Carleton Foodorama (Part 1) Due: Friday, July 14 th 2006, before 11h55 pm

COMP 1006/1406 Assignment 1 Carleton Foodorama (Part 1) Due: Friday, July 14 th 2006, before 11h55 pm COMP 006/406 Assignment Carleton Foodorama (Part ) Due: Friday, July 4 th 2006, before h55 pm In this assignment, you will review basic concepts from COMP 005. You will get to design a simple text-based

More information

Based on slides by Prof. Burton Ma

Based on slides by Prof. Burton Ma Based on slides by Prof. Burton Ma 1 TV - on : boolean - channel : int - volume : int + power(boolean) : void + channel(int) : void + volume(int) : void Model View Controller RemoteControl + togglepower()

More information

Week Chapter Assignment SD Technology Standards. 1,2, Review Knowledge Check JP3.1. Program 5.1. Program 5.1. Program 5.2. Program 5.2. Program 5.

Week Chapter Assignment SD Technology Standards. 1,2, Review Knowledge Check JP3.1. Program 5.1. Program 5.1. Program 5.2. Program 5.2. Program 5. Week Chapter Assignment SD Technology Standards 1,2, Review JP3.1 Review exercises Debugging Exercises 3,4 Arrays, loops and layout managers. (5) Create and implement an external class Write code to create

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

Contents Chapter 1 Introduction to Programming and the Java Language

Contents Chapter 1 Introduction to Programming and the Java Language Chapter 1 Introduction to Programming and the Java Language 1.1 Basic Computer Concepts 5 1.1.1 Hardware 5 1.1.2 Operating Systems 8 1.1.3 Application Software 9 1.1.4 Computer Networks and the Internet

More information

CMP 326 Midterm Fall 2015

CMP 326 Midterm Fall 2015 CMP 326 Midterm Fall 2015 Name: 1) (30 points; 5 points each) Write the output of each piece of code. If the code gives an error, write any output that would happen before the error, and then write ERROR.

More information

GUI Applications. Let s start with a simple Swing application in Java, and then we will look at the same application in Jython. See Listing 16-1.

GUI Applications. Let s start with a simple Swing application in Java, and then we will look at the same application in Jython. See Listing 16-1. GUI Applications The C implementation of Python comes with Tkinter for writing Graphical User Interfaces (GUIs). The GUI toolkit that you get automatically with Jython is Swing, which is included with

More information

This document shows the whole program for the implementation of the Withdraw operation specication.

This document shows the whole program for the implementation of the Withdraw operation specication. This document shows the whole program for the implementation of the Withdraw operation specication. * Account.java * 1 package ATM_BasicClasses; 3 import java.util.date; 4 5 public class Account { 6 public

More information

Agenda. Container and Component

Agenda. Container and Component Agenda Types of GUI classes/objects Step-by-step guide to create a graphic user interface Step-by-step guide to event-handling PS5 Problem 1 PS5 Problem 2 Container and Component There are two types of

More information

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1 Datenbank-Praktikum Universität zu Lübeck Sommersemester 2006 Lecture: Swing Ho Ngoc Duc 1 Learning objectives GUI applications Font, Color, Image Running Applets as applications Swing Components q q Text

More information

package As7BattleShip;

package As7BattleShip; package As7BattleShip; Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: Runs the battleship game Input: ship placement board files and computer player type Output:

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2009 FINAL EXAMINATION 14 DECEMBER 2009 Instructor: Alan McLeod If the instructor is unavailable

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2009 FINAL EXAMINATION 14 DECEMBER 2009 SOLUTION Instructor: Alan McLeod If the instructor is unavailable

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

Chapter 12 GUI Basics

Chapter 12 GUI Basics Chapter 12 GUI Basics 1 Creating GUI Objects // Create a button with text OK JButton jbtok = new JButton("OK"); // Create a label with text "Enter your name: " JLabel jlblname = new JLabel("Enter your

More information