Guest User

Untitled

a guest
Jun 24th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileNotFoundException;
  3. import java.io.FileReader;
  4. import java.io.IOException;
  5. import java.util.regex.Matcher;
  6. import java.util.regex.Pattern;
  7. //import org.apache.commons.lang.StringUtils;
  8.  
  9. /*
  10. * Alan Ruvalcaba
  11. * CS 301 12:00 - 12:50am
  12. *
  13. */
  14.  
  15. public class Huntingtons {
  16.  
  17. public static void main(String[] args) throws IOException {
  18.  
  19. BufferedReader in = new BufferedReader(new FileReader(args[0]));
  20. StringBuffer result = new StringBuffer();//Create StringBuffer
  21. String iterator = "";
  22. while ((iterator = in.readLine()) != null) {
  23. result.append(iterator);
  24. }
  25. String copyNospace = new String(result);
  26. copyNospace = copyNospace.replaceAll("\\s", "");
  27. countOccurrences(copyNospace);
  28. }
  29.  
  30. public static void countOccurrences(String input) {
  31. Pattern pattern = Pattern.compile("(C\\s*A\\s*G\\s*)*");
  32.  
  33. Matcher matcher = pattern.matcher(input);
  34. int max = 0;
  35. while(matcher.find()){
  36. //System.out.println(matcher.group().length());
  37. int length = matcher.group().length();
  38. if(max < length/3)
  39. max = length/3;
  40.  
  41. }
  42.  
  43. if (max < 28)
  44. System.out.println("< 28 Normal " + max);
  45. else if (max >= 28 && max <= 35)
  46. System.out
  47. .println("28-35 Intermediate Level,no symptoms " + max);
  48. else if (max >= 36 && max <= 39)
  49. System.out.println("36-39 At risk for Huntington's Disease "
  50. + max);
  51. else if (max >= 40 && max <= 180)
  52. System.out.println("40-180 Huntington's Disease " + max);
  53. else if (max > 180)
  54. System.out.println("> 180 Not a human being.");
  55. }
  56. }
Add Comment
Please, Sign In to add comment