zoukankan      html  css  js  c++  java
  • 0414-复利计算升级--结对

    今次的实验主要是和小伙伴对复利计算器的程序进行了升级,也就是加多了界面上去,我们一共做了两个界面,

    主要是用的组件不一样,我们也把之前不熟悉的组件也都尝试了一遍,效果还不错。在尝试时,我们有各自的

    不同想法,边想边做,遇到问题就一起讨论,所以就出现了两个不同的版本。在这里我和小伙伴分别把两个不

    同的界面发到各自的博客园上,103李康梅http://www.cnblogs.com/88mei,具体代码请看:

      这是其中的一个界面。另一个界面如下:
    private void jComboBox0MouseMouseClicked(MouseEvent event) {
    	       if(jComboBox0.getSelectedItem()=="复利"){
    	    	  this.jLabel0.setText("本金:");
    	    	  this.jLabel1.setText("利率:");
    	    	  this.jLabel2.setText("期限:");
    	    	  this.jLabel3.setText("终值:");
    	       }
    	       else if(jComboBox0.getSelectedItem()=="本金"){
    	    	   this.jLabel0.setText("终值:");
    	    	   this.jLabel1.setText("利率:");
    	    	   this.jLabel2.setText("期限:");
    	    	   this.jLabel3.setText("本金:");
    	       }
    	       else if(jComboBox0.getSelectedItem()=="单利"){
    	    	   this.jLabel0.setText("本金:");
    	    	   this.jLabel1.setText("利率:");
    	    	   this.jLabel2.setText("期限:");
    	    	   this.jLabel3.setText("终值:");
    	       }
    	       else if(jComboBox0.getSelectedItem()=="利率"){
    	    	   this.jLabel0.setText("终值:");
    	    	   this.jLabel1.setText("本金:");
    	    	   this.jLabel2.setText("期限:");
    	    	   this.jLabel3.setText("利率:");
    	       }
    	       else if(jComboBox0.getSelectedItem()=="期限"){
    	    	   this.jLabel0.setText("本金:");
    	    	   this.jLabel1.setText("利率:");
    	    	   this.jLabel2.setText("终值:");
    	    	   this.jLabel3.setText("期限:");
    	       }
    	       else if(jComboBox0.getSelectedItem()=="资产总值"){
    	    	   this.jLabel0.setText("本金:");
    	    	   this.jLabel1.setText("利率:");
    	    	   this.jLabel2.setText("期限:");
    	    	   this.jLabel3.setText("资产总值:");
    	       }
    	        else if(jComboBox0.getSelectedItem()=="每月等额还款"){
    	    	   this.jLabel0.setText("借款:");
    	    	   this.jLabel1.setText("利率:");
    	    	   this.jLabel2.setText("期限:");
    	    	   this.jLabel3.setText("月还款:");
    	       }
    	}
    	public void run()
    	{
    		try{
    			double f=0;
    			//当输入值为空,结果返回0
    			if(jTextField0.getText().equals("") ||jTextField1.getText().equals("") ||jTextField2.getText().equals(""))
    			{
    			  jLabel4.setText("请输入>0的数字");	
    			  jLabel5.setText("请输入>0的数字");
    			  jLabel6.setText("请输入>0的数字");
    			}else{
    				NumberFormat currencyformatter=NumberFormat.getCurrencyInstance();//字符串转化为数字
    				float P=Float.parseFloat(jTextField0.getText());
    				float r=Float.parseFloat(jTextField1.getText());
    				float N=Float.parseFloat(jTextField2.getText());
    				if(P<=0)
    				{
    					jLabel4.setText("请输入>0的数字");
    				}
    				if(r<=0)
    				{
    					jLabel5.setText("请输入>0的数字");
    				}
    				if(N<=0)
    				{
    					jLabel6.setText("请输入>0的数字");
    				}
    				if(P>0&&r>0&&N>0)
    				{
    					if(jComboBox0.getSelectedItem()=="复利"){
    						f=P*(Math.pow((1+r), N));
    					}
    					if(jComboBox0.getSelectedItem()=="单利"){
    						f=P+P*N*r;
    					}
    					if(jComboBox0.getSelectedItem()=="本金"){
    						f=P / Math.pow((1 + r), N);
    					}
    					if(jComboBox0.getSelectedItem()=="利率"){
    						f=Math.pow(P/r,1d/N);
    					}
    					if(jComboBox0.getSelectedItem()=="期限"){
    						f=(Math.log(N)/Math.log(1+r))-(Math.log(P)/Math.log(1+r));
    					}
    					if(jComboBox0.getSelectedItem()=="资产总值"){
    						f=P*(Math.pow((1+r), N)-1)/r;
    					}
    					if(jComboBox0.getSelectedItem()=="每月等额还款"){
    						f=(P+(P*r)*N)/12;
    					}
    				}
    				DecimalFormat df = new DecimalFormat("0.00");
                    String db = df.format(f);
                    jTextField4.setText(String.valueOf(db));
    			}
    			
    		}
    	catch (Exception e) {
            System.out.println(e.getMessage());
    	}
    }
    
    	private void jButton0MouseMouseClicked(MouseEvent event) {
    		run();
    	}
    	
    }
    

                               

    具体代码请看:https://github.com/xinxiangzhang/me.git

    虽然没有很好,但两个人一起完成两个版本,即使基本功能一样,但所学会的知识还是比较多。此次合作配合比之前好了许多。

  • 相关阅读:
    173. Binary Search Tree Iterator
    199. Binary Tree Right Side View
    230. Kth Smallest Element in a BST
    236. Lowest Common Ancestor of a Binary Tree
    337. House Robber III
    449. Serialize and Deserialize BST
    508. Most Frequent Subtree Sum
    513. Find Bottom Left Tree Value
    129. Sum Root to Leaf Numbers
    652. Find Duplicate Subtrees
  • 原文地址:https://www.cnblogs.com/xyz--123/p/5392159.html
Copyright © 2011-2022 走看看