willkill104

willkill104

  • Member since: 10/26/2010
  • Gender: Male
 
 
15Games Rated 4Comments 0Forum Posts 0Games Submitted 0Merits

willkill104's Quests (6)

Show All Quests

The Messenger

Rules and Guidelines

You must be logged in to post a comment!

  1. added for dotd, add me back

  2. Added back!

  3. Added back. =)

  4. //variables
            String firstName, middleName, lastName, fullNameCaps;
            String fullNameLowerTwoHyphen, fullNameLowerOneHyphen;
            String fullNameNoHyphens, fullNameNoHyphenPartOne;
            String fullNameNoHyphenPartTwo;
            String SPACE = " " ;
            String HYPHEN = "-";
            int hyphenLocationOne, hyphenLocationTwo;
            Boolean nameCaseMatters, nameCaseDoesNotMatter;
           
            //request
            System.out.print("Enter your first, middle, "
                + "and last names
    (use upper case letters and a "
                + "space between each name): ");
            fullNameCaps = Keyboard.readString();
            System.out.print("
    Enter your first, middle,"
                + "and last names
    (use lower case letters and a "
                + "hyphen between each name): ");
            fullNameLowerTwoHyphen = Keyboard.readString();
           
            //remove first Hyphen
            hyphenLocationOne = fullNameLowerTwoHyphen.indexOf(HYPHEN);
            firstName =
                fullNameLowerTwoHyphen.substring(0, hyphenLocationOne);
           
            //remove second Hyphen
            fullNameLowerOneHyphen =
                fullNameLowerTwoHyphen.substring(hyphenLocationOne + 1);
            hyphenLocationTwo = fullNameLowerOneHyphen.indexOf(HYPHEN);
            middleName =
                fullNameLowerOneHyphen.substring(0, hyphenLocationTwo);
            lastName =
                 fullNameLowerOneHyphen.substring(hyphenLocationTwo + 1);
           
            //name combined
            fullNameNoHyphenPartOne =
                firstName.concat(SPACE.concat(middleName));
            fullNameNoHyphenPartTwo = SPACE.concat(lastName);
                fullNameNoHyphens =
                    fullNameNoHyphenPartOne.concat(fullNameNoHyphenPartTwo);
           
            //name with no hyphens
            System.out.println("
    your name with no hyphens is: "
                + fullNameNoHyphens);
           
            //equality
            nameCaseMatters = fullNameCaps.equals(fullNameNoHyphens);
            nameCaseDoesNotMatter =
                fullNameCaps.equalsIgnoreCase(fullNameNoHyphens);
           
            //output
            System.out.println("
    Are the names " + fullNameCaps
                + " and " + fullNameNoHyphens
                + "
    the same if we do not "
                + "ignore capitals? " + nameCaseMatters);
            System.out.println("
    Are the name " + fullNameCaps
                + " and " + fullNameNoHyphens + "
    the same if we "
                + "ignore capitals? " + nameCaseDoesNotMatter);