Advertisement
Transformator

Untitled

Jan 10th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. public float testSameUser(String user1, String user2) {
  2.         if(user1.length() != user2.length()) {
  3.             System.out.println("[ERROR] Uservalues don't have the same length!");
  4.             return 0F;
  5.         }
  6.        
  7.         int sameAnswers = 0;
  8.        
  9.         char[] user1char = user1.toCharArray();
  10.         char[] user2char = user2.toCharArray();
  11.        
  12.         for(int i=0; i<user1.length(); i++) {
  13.             if(user1char[i] == user2char[i]) {
  14.                 sameAnswers++;
  15.             }
  16.         }
  17.        
  18.         return sameAnswers/user1.length();
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement