Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   Convert java to mips assembley (http://www.go4expert.com/forums/convert-java-mips-assembley-t23598/)

 mohm200 18Oct2010 02:25

Convert java to mips assembley

Comparing each character in the first string with the character at the same index in the second string and compute the number of different characters in the two strings. (ex. Strings_ Difference("atalk","took")=
diff is = 5
and
Compute the difference between the two strings in length.(ex. Strings_Difference("tall","talls") =1 because the string books has one character more than the string book).
The difference between the two strings in length = 1 ----- ( First String is Longer)

************************************************** **********
Code:

```  public class NewClass1 {   public static void main (String args[] ) {         char []a;         char []b;         String s1 = "atalk";         String s2 = "took";         int max=0;         int diff=0;         if(s1.length()>s2.length()){               max =s1.length();                                     }               else max =s2.length();         a = new char [max];         b = new char [max];         for(int i=0 ; i<s1.length() ; i++){               a[i]=s1.charAt(i);                                           }         for(int i=0 ; i<s2.length() ; i++){               b[i]=s2.charAt(i);                                           }       for (int i=0 ; i<max ;i++){             if (a[i]== b[i]);                 else diff+=1;                                 }       System.out.println("  diff is = " + diff );               diff(s1,s2);                                               }               public static void diff(String c , String d){             int a = c.length();             int b = d.length();             int differance =a-b;             int max;             if (a>b){                 max =a;                     }                 else max=b;             if(differance > 0)                       System.out.println( "  The difference between the two strings in length =  " + differance + "    ----- ( First String is Longer) " );                 else System.out.println( "  The difference between the two strings in length =  " + differance + "    ----- ( Second String is Longer)");                                                     }                                                     }```

 All times are GMT +5.5. The time now is 04:30.