0309 Compound Interest Calculation software

Source: Internet
Author: User

Job Requirements: Customer said: Help me develop a compound interest calculation software. Complete the compounding Formula calculation program and push it successfully onto GitHub.

Code:

 Packagech1;Importjava.awt.Dimension;Importjava.awt.FlowLayout;Importjava.awt.GridLayout;Importjava.awt.event.ActionEvent;ImportJava.awt.event.ActionListener;ImportJava.text.NumberFormat;ImportJavax.swing.JButton;ImportJavax.swing.JFrame;ImportJavax.swing.JLabel;ImportJavax.swing.JPanel;ImportJavax.swing.JScrollPane;ImportJavax.swing.JTextArea;ImportJavax.swing.JTextField; Public classInterestextendsJFrame {Private Static Final LongSerialversionuid = 3347254632537686808L;PrivateJLabel A1;PrivateJLabel A2;PrivateJLabel A3;PrivateJTextField B1;PrivateJTextField B2;PrivateJTextField B3;PrivateJButton C1;PrivateJButton C2;PrivateJTextArea text; PublicInterest () {creatcomponents (); layoutcomponents (); Registerhandlers (); Settitle ("Compound Deposit Application"); Setdefaultcloseoperation (jframe.exit_on_close);p ack ();}Private voidcreatcomponents () {A1=NewJLabel ("Principal"); A2=NewJLabel ("annual interest rate")); A3=NewJLabel ("Number of years"); B1=NewJTextField (10); B2=NewJTextField (10); B3=NewJTextField (10); C1=NewJButton ("Calculation"); C2=NewJButton ("Clear"); text=NewJTextArea ();}Private voidlayoutcomponents () {setlayout (NewFlowLayout ()); JPanel Panel1=NewJPanel ();p anel1.add (A1);p Anel1.add (B1); JPanel Panel2=NewJPanel ();p anel2.add (A2);p anel2.add (B2); JPanel Panel3=NewJPanel ();p anel3.add (A3);p Anel3.add (B3); JPanel Panel4=NewJPanel ();p Anel4.add (C1);p Anel4.add (C2); JPanel Leftpanel=NewJPanel (NewGridLayout (4, 1) ; Leftpanel.add (Panel1); Leftpanel.add (Panel2); Leftpanel.add (PANEL3); Leftpanel.add (PANEL4); JScrollPane Panel5=NewJScrollPane (text);p anel5.setpreferredsize (NewDimension (200, 150) ; add (Leftpanel); add (Panel5);}Private voidregisterhandlers () {C1actioneventhander hander1=NewC1actioneventhander (); C1.addactionlistener (hander1); C2actioneventhander hander2=NewC2actioneventhander (); C2.addactionlistener (hander2);//c3actioneventhander hander3=new C3actioneventhander ();}Private classC1actioneventhanderImplementsActionListener { Public voidactionperformed (ActionEvent e) {Doubleprincipal;Doubleamount;DoubleRate ;intN; NumberFormat Currencyformatter=numberformat.getcurrencyinstance (); String Output= "Year" + "/" + "compound deposit";intYear = 1;p Rincipal=double.parsedouble (B1.gettext ());=double.parsedouble (B2.gettext ()); n=Integer.parseint (B3.gettext ()); while(Year <=N) {amount= Principal * MATH.POW (1 +Rate , year); output+ = string.valueof (year) + "\ T" + currencyformatter.format (amount) + "\ n"; Year= year + 1;} Text.settext (output);}}Private classC2actioneventhanderImplementsActionListener { Public voidactionperformed (ActionEvent e) {B1.settext (""); B2.settext (""); B3.settext (""); Text.settext ("");}} Public Static voidMain (string[] args) {Interest frame=NewInterest (); Frame.setvisible (true); Frame.setsize (450, 200); Frame.setresizable (false);}}

interface and results.

0309 Compound Interest Calculation software

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.