Possible Duplicate:
Convert java to mips
i write this code in java now i want to convert it to mips i dont learn mips can any help me ????????
now explain code
this code is to
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 this code compare to string and the diff is 5 why?
because in string 1 first char is a and in second is t in string 1 second char is t and in string 2 second is o ect... this is how to find diff
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).
after compute differance this is output =1 but i write more string to explain it
The difference between the two strings in length = 1
public class NewClass1 {
public static void main (String args[] ) {
//two trings to be compare
String s1 = "ataok";
String s2 = "took";
// integer to find differance between two string
int differance =s1.length()-s2.length();
// method to compare each char in two strings
diff(s1,s2);
// to print output The difference between the two strings in length
System.out.println( " The difference between the two strings in length = " + differance);
}
//method to compare
public static void diff(String s1 , String s2){
//define two array of char to put strings in it
char []a;
char []b;
// max to find the longer string to be the dimention of two array (same dim)
int max=0;
//variable to be increase when char in string1 != char in string 2
int diff=0;
// find max string in lenght
if(s1.length()>s2.length())
max =s1.length();
else max =s2.length();
//put strings in array of char
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);
}
// copmare two string each char
for (int i=0 ; i<max ;i++){
if (a[i]== b[i]);
else diff+=1;
}
System.out.println(" diff is = " + diff );
}
}