Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. //© A+ Computer Science - www.apluscompsci.com
  2. //Name -
  3. //Date -
  4. //Class -
  5. //Lab -
  6.  
  7. import static java.lang.System.*;
  8. import java.util.Scanner;
  9.  
  10. public class StringOddOrEven
  11. {
  12. private String word;
  13.  
  14. public StringOddOrEven()
  15. {
  16. word="";
  17. }
  18.  
  19. public StringOddOrEven(String s)
  20. {
  21. word=s;
  22. }
  23.  
  24. public void setString(String s)
  25. {
  26. word=s;
  27. }
  28.  
  29. public boolean isEven()
  30. {
  31. if(word.length()%2==0)
  32. return true;
  33. else
  34. return false;
  35. }
  36.  
  37. public String toString()
  38. {
  39. String output="";
  40. output+=word;
  41. if(isEven())
  42. output+=" is even";
  43. else
  44. output+=" is odd";
  45. return output;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement