Question

AddressHelper Written in - JAVA Write a class called AddressHelper that provides the following static methods...

AddressHelper

Written in - JAVA

Write a class called AddressHelper that provides the following static methods to help with

     formatting and printing addresses:

addMrPrefix()

Returns the string “Mr. “ concatenated with the String argument.

addMsPrefix()

Returns the string “Ms. “ concatenated with the String argument.

determineStateAbbreviation()

Takes a String argument containing a state. Returns the corresponding

abbreviation as String using the following lookup table:

New York NY

New Jersey NJ

California CS

Florida FL

other --

determineZipcode()

Takes a String argument containing a city. Returns the corresponding

zipcode as int using the following lookup table:

Manhattan 10001

Los Angeles 90001

Chicago 60007

Boston 01841

other 00000

asString()

Takes name, street address, city, state, and zip code as arguments. Returns a

String concatenating each argument separated by the newline character.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for posting the question, we are glad to help you. Here are all the implemented methods your will be needing for the questions;

_________________________________________________________________________________________________

public class AddressHelper {

    public static String addMrPrefix(String name) {
        return "Mr. " + name;
    }

    public static String addMsPrefix(String name) {
        return "Ms. " + name;
    }

    public static String getStateAbbreviation(String state) {

        if (state.equalsIgnoreCase("new york")) {
            return "NY";
        } else if (state.equalsIgnoreCase("new jersey")) {
            return "NJ";
        } else if (state.equalsIgnoreCase("california")) {
            return "CS";
        } else if (state.equalsIgnoreCase("florida")) {
            return "FL";
        } else {
            return "";
        }
    }

    public static String getZipCode(String state) {

        if (state.equalsIgnoreCase("manhattan")) {
            return "10001";
        } else if (state.equalsIgnoreCase("los angeles")) {
            return "90001";
        } else if (state.equalsIgnoreCase("chicago")) {
            return "60007";
        } else if (state.equalsIgnoreCase("boston")) {
            return "01841";
        } else {
            return "00000";
        }
    }

    public String getConcatenated(String name, String stAddress, String city, String state, String zip) {

        StringBuilder builder = new StringBuilder();
        builder.append(stAddress).append("\n");
        builder.append(city).append("\n");
        builder.append(state).append("\n");
        builder.append(zip).append("\n");

        return builder.toString();
    }
}

______________________________________________________________________________________________

Thanks a lot !

friend : )

Add a comment
Know the answer?
Add Answer to:
AddressHelper Written in - JAVA Write a class called AddressHelper that provides the following static methods...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA Create a Governor class with the following attributes: name : String party - char (the...

    JAVA Create a Governor class with the following attributes: name : String party - char (the character will be either D, R or I) ageWhenElected : int Create a State class with the following attributes: name : String abbreviation : String population : long governor : Governor Your classes will have all setters, getters, typical methods to this point (equals(), toString()) and at least 3 constructors (1 must be the default, 1 must be the copy). You will be turning...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT