Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //© A+ Computer Science - www.apluscompsci.com
- //Name -
- //Date -
- //Class -
- //Lab -
- import static java.lang.System.*;
- import java.util.Scanner;
- public class StringOddOrEven
- {
- private String word;
- public StringOddOrEven()
- {
- word="";
- }
- public StringOddOrEven(String s)
- {
- word=s;
- }
- public void setString(String s)
- {
- word=s;
- }
- public boolean isEven()
- {
- if(word.length()%2==0)
- return true;
- else
- return false;
- }
- public String toString()
- {
- String output="";
- output+=word;
- if(isEven())
- output+=" is even";
- else
- output+=" is odd";
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement