Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. package ConditionTask;
  2.  
  3. public class ActivityRecorder {
  4.  
  5. public static int activityRecorder(String[] activities, int year) {
  6. int total = 0;
  7. for (String activity : activities) {
  8. if (activity == "TypeA") {
  9. total += 20;
  10. }
  11. if (activity == "TypeC") {
  12. total += 13;
  13. }
  14. if (activity == "TypeE" || activity == "TypeG" || activity == "TypeH") {
  15. total += 7;
  16. }
  17. if (activity == "TypeJ" || activity == "TypeL") {
  18. total += 3;
  19. }
  20. if (activity == "TypeD" || activity == "TypeF") {
  21. total += 10;
  22. }
  23. if (activity == "TypeI" || activity == "TypeK") {
  24. total += 9;
  25. }
  26. if (activity == "TypeB") {
  27. if (((year % 4 == 0) && !(year % 100 == 0)) || (year % 400 == 0))
  28. total += 3;
  29. else
  30. total += 2;
  31. }
  32. if (activity != "TypeA" && activity != "TypeB" && activity != "TypeC" && activity != "TypeD"
  33. && activity != "TypeE" && activity != "TypeF" && activity != "TypeG" && activity != "TypeH"
  34. && activity != "TypeI" && activity != "TypeJ" && activity != "TypeK" && activity != "TypeL") {
  35. total = 20;
  36. }
  37.  
  38. }
  39.  
  40. return total;
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement