Compounding Plan 1.0

Source: Internet
Author: User

Package Fuli;import Java.awt.color;import Java.awt.event.mouseadapter;import java.awt.event.mouseevent;import Java.text.numberformat;import Javax.swing.defaultcomboboxmodel;import Javax.swing.jbutton;import Javax.swing.jcombobox;import Javax.swing.jframe;import Javax.swing.jlabel;import Javax.swing.JPanel;import Javax.swing.jtextfield;import Javax.swing.swingutilities;import Javax.swing.uimanager;import Javax.swing.border.lineborder;import Org.dyno.visual.swing.layouts.constraints;import Org.dyno.visual.swing.layouts.grouplayout;import org.dyno.visual.swing.layouts.leading;//vs4e--Do not REMOVE the This    Line!public class Fuli extends JFrame {private static final long serialversionuid = 1L;    Private JLabel jLabel0;    Private JLabel JLabel1;    Private JPanel JPanel1;    Private JPanel jPanel0;    Private JLabel JLabel2;    Private JButton JButton4;    Private JLabel jLabel3;    Private JTextField jTextField0;    Private JTextField jTextField1;    Private JTextField jTextField2;Private JTextField jTextField3;    private static final MouseEvent event2 = null;    Private JComboBox jComboBox0;    Private JComboBox JComboBox1;    Private JButton JButton1;    Private JLabel JLabel4;    private static final String Preferred_look_and_feel = "Javax.swing.plaf.metal.MetalLookAndFeel";    Public Fuli () {initcomponents ();        } private void Initcomponents () {setlayout (New grouplayout ());        Add (GetJPanel0 (), New Constraints (new leading (9, 304, ten), new leading (80, 361, 10, 10));        Add (GetJComboBox1 (), New Constraints (new leading (Max., ten), new leading (19, 10, 10));    SetSize (320, 449);            } private JLabel GetJLabel4 () {if (JLabel4 = = null) {JLabel4 = new JLabel ();        Jlabel4.settext ("%");    } return jLabel4;            } private JButton GetJButton1 () {if (JButton1 = = null) {JButton1 = new JButton ();            Jbutton1.settext ("OK"); Jbutton1.addmouselistener (New Mouseadapter () {public void mouseclicked (MouseEvent event) {JBUTTON1MOUSEMOUSECLI                Cked (event);        }            });    } return jButton1;            } private JComboBox GetJComboBox1 () {if (JComboBox1 = = null) {JComboBox1 = new JComboBox ();            Jcombobox1.setmodel (New DefaultComboBoxModel (new object[] {"Compound calculation", "Simple Interest Calculation"}));            Jcombobox1.setdoublebuffered (FALSE);            Jcombobox1.setborder (NULL);        Jcombobox1.addmouselistener (New Mouseadapter () {});    } return jComboBox1;            } private JComboBox getJComboBox0 () {if (jComboBox0 = = null) {jComboBox0 = new JComboBox ();            Jcombobox0.setmodel (New DefaultComboBoxModel (new object[] {"Final value calculation", "Principal calculation", "Life calculation", "Interest Calculation"}));            Jcombobox0.setdoublebuffered (FALSE);            Jcombobox0.setborder (NULL);        Jcombobox0.addmouselistener (New Mouseadapter () {});     }   return jComboBox0;        } private JTextField getJTextField3 () {if (jTextField3 = = null) {jTextField3 = new JTextField (10);    } return jTextField3;        } private JTextField GetJTextField2 () {if (jTextField2 = = null) {jTextField2 = new JTextField ();    } return jTextField2;        } private JTextField GetJTextField1 () {if (jTextField1 = = null) {jTextField1 = new JTextField (10);    } return jTextField1;        } private JTextField getJTextField0 () {if (jTextField0 = = null) {jTextField0 = new JTextField (10);    } return jTextField0;            } private JLabel GetJLabel3 () {if (jLabel3 = = null) {jLabel3 = new JLabel ();        Jlabel3.settext ("final value");    } return JLABEL3;            } private JButton GetJButton4 () {if (JButton4 = = null) {JButton4 = new JButton ();            Jbutton4.settext ("OK"); Jbutton4.addmOuselistener (New Mouseadapter () {public void mouseclicked (MouseEvent event) {Jbutt                On4mousemouseclicked (event);        }            });    } return jButton4;            } private JLabel GetJLabel2 () {if (JLabel2 = = null) {JLabel2 = new JLabel ();        Jlabel2.settext ("interest rate");    } return JLabel2;            } private JPanel GetJPanel0 () {if (jPanel0 = = null) {jPanel0 = new JPanel ();            Jpanel0.setborder (New Lineborder (Color.Red, 1, false));            Jpanel0.setlayout (New Grouplayout ());            Jpanel0.add (GetJPanel1 (), New Constraints (new leading (n, 261, ten), new leading (74, 264, 10, 10));            Jpanel0.add (GetJComboBox0 (), New Constraints (new leading (), new leading (20, 10, 10));        Jpanel0.add (GetJButton1 (), New Constraints (new leading (119, ten, ten), new leading (19, 12, 12));    } return jPanel0; } Private JPanel GetjpanEl1 () {if (JPanel1 = = null) {JPanel1 = new JPanel ();            Jpanel1.setborder (New Lineborder (Color.Black, 1, false));            Jpanel1.setlayout (New Grouplayout ());            Jpanel1.add (GetJLabel0 (), New Constraints (new leading (), new leading (26, 10, 10));            Jpanel1.add (GetJLabel1 (), New Constraints (new leading), new leading (113, 10, 10));            Jpanel1.add (GetJLabel2 (), New Constraints (new leading (n, N, N), new leading (70, 10, 10));            Jpanel1.add (GetJButton4 (), New Constraints (new leading, new leading (161, 10, 10));            Jpanel1.add (GetJLabel3 (), New Constraints (new leading), new leading (215, 10, 10));            Jpanel1.add (GetJTextField0 (), New Constraints (new leading, 182, ten, new leading (26, 12, 12));            Jpanel1.add (GetJTextField3 (), New Constraints (new leading (, 178, N, N), new leading (213, 12, 12)); Jpanel1.add (GetJTextField1 (), New constrAints (new leading (113, 182, N, a), new leading (12, 12));            Jpanel1.add (GetJLabel4 (), New Constraints (new leading (72, 12, 12), new leading);        Jpanel1.add (GetJTextField2 (), New Constraints (new leading (70, 12, 12)), new 158 ();    } return JPanel1;            } private JLabel GetJLabel1 () {if (JLabel1 = = null) {JLabel1 = new JLabel ();        Jlabel1.settext ("Years");    } return JLabel1;            } private JLabel GetJLabel0 () {if (jLabel0 = = null) {jLabel0 = new JLabel ();        Jlabel0.settext ("principal");    } return jLabel0;            } private static void Installlnf () {try {String lnfclassname = Preferred_look_and_feel;            if (Lnfclassname = = null) Lnfclassname = Uimanager.getcrossplatformlookandfeelclassname ();        Uimanager.setlookandfeel (Lnfclassname); } catch (Exception e) {System.err.println ("Cannot install" + Preferred_look_and_feel + "on this platform:" + e.getmessage ());    }}/** * Main entry of the class.    * Note:this class is only created so and can easily preview the result at runtime.    * It is not expected to being managed by the designer.    * Can modify it as you like.        */public static void main (string[] args) {installlnf ();                Swingutilities.invokelater (New Runnable () {public void run () {Fuli frame = new Fuli (); Frame.setdefaultcloseoperation (Fuli.                Exit_on_close);                Frame.settitle ("Compound interest, simple interest calculation");                Frame.getcontentpane (). Setpreferredsize (Frame.getsize ());                Frame.pack ();                Frame.setlocationrelativeto (NULL);            Frame.setvisible (TRUE);    }        }); }//Final value, principal private void jbutton1mousemouseclicked (MouseEvent event) {if (Jcombobox0.getselecteditem () = = "Final Value meter ") {JPanel1 = new JPanel();            jTextField0 = new JTextField ();            JTextField1 = new JTextField ();            JTextField2 = new JTextField ();        jTextField3 = new JTextField ();            } else if (jcombobox0.getselecteditem () = = "Principal calculation") {JPanel1 = new JPanel ();            This.jLabel0.setText ("final value");        This.jLabel3.setText ("principal");            } else if (jcombobox0.getselecteditem () = = "Age calculation") {JPanel1 = new JPanel ();            This.jLabel0.setText ("principal");            This.jLabel1.setText ("final value");        This.jLabel3.setText ("Years");            } else if (jcombobox0.getselecteditem () = = "Interest calculation") {JPanel1 = new JPanel ();            This.jLabel0.setText ("principal");            This.jLabel3.setText ("interest");        This.jLabel1.setText ("Years"); }} private void Jbutton4mousemouseclicked (MouseEvent event) {NumberFormat Currencyformatter = numberfor         Mat.getcurrencyinstance (); Double p = double.parsedouble (JTextField0.getText ());        Double r = double.parsedouble (Jtextfield1.gettext ());        Double n = double.parsedouble (Jtextfield2.gettext ());        Double f=0;                if (jcombobox1.getselecteditem () = = "Compound calculation") {if (Jcombobox0.getselecteditem () = = "Final value calculation") {            f = p * Math.pow ((1 + 0.01*r), n);            } else if (jcombobox0.getselecteditem () = = "Principal calculation") {f = P/math.pow ((1+0.01*r), n);            } else if (jcombobox0.getselecteditem () = = "Age calculation") {f=0;            } else if (jcombobox0.getselecteditem () = = "Interest calculation") {F=p * Math.pow ((1 + 0.01*r), n)-1;            }} else {if (jcombobox0.getselecteditem () = = "Final value calculation") {f = p* (1+0.01*r*n);            } else if (jcombobox0.getselecteditem () = = "Principal calculation") {f = p/(1+0.01*r*n); } else if (jcombobox0.getselecteditem () = = "Age calculation") {f=0;            } else if (jcombobox0.getselecteditem () = = "Interest calculation") {f=p* (1+0.01*r*n)-p;    }} jtextfield3.settext (String.valueof (f)); }}

Compounding Plan 1.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.