private static void getPlus(String a, String b) { 
//                1. 获取第一个数的分子和分母。 
                String[] tempStr1=a.split("/"); 
                int top1=Integer.parseInt(tempStr1[0]); 
                int bottom1=Integer.parseInt(tempStr1[1]); 
                int tempint1=top1/bottom1; 
                int tempfloat1=top1%bottom1; 
//                2. 获取第二个数的分子和分母 
                String[] tempStr2=b.split("/"); 
                int top2=Integer.parseInt(tempStr2[0]); 
                int bottom2=Integer.parseInt(tempStr2[1]); 
                int tempint2=top2/bottom2; 
                int tempfloat2=top2%bottom2; 
//                3. 进行分子分母运算。 
                int calBottom=bottom1*bottom2; 
                int calTop=(tempint1*calBottom+tempfloat1*bottom2)+(tempint2*calBottom+tempfloat2*bottom1); 
//                System.out.println(calTop+"/"+calBottom); 
//                4. 对分子分母进行化简 
                for(int i=2;i<=bottom1*bottom2;i++){ 
                        if(calTop%i==0&calBottom%i==0){ 
                                int finalTop=calTop/i; 
                                int finalBottom=calBottom/i; 
                                System.out.println(finalTop+"/"+finalBottom); 
                                break; 
                        } 
                        else if(i==bottom1*bottom2){ 
                                System.out.println(calTop+"/"+calBottom); 
                        } 
                } 
        } 
 |   
        
 
    
    
    
     
 
 |