Ask Questions?

View Latest Questions

Advertisement


 
 

Programming - Flip Name
Posted on: July 26, 2006 at 12:00 AM
Write a method, flipName, which has a string parameter which contains a name in last, first format.

Java: Programming - Flip Name

 

Name ______________________

Write a method, flipName, which has a string parameter which contains a name in last, first format.

It should return the name in first last format as a string, or "ERROR" if the argument was not correctly formed.

You can learn it from the program given below.

You should modify and make some change in program to learn the concept in detail.

For example, the following main program.

public static void main(String[] args) {
    System.out.println(
       flipName("Maus, Michael"));
    System.out.println(flipName(
      "Einstein, Albert"));
    System.out.println(flipName(
     "Prince Albert"));
    System.out.println(
   flipName(null));
}

The output would be.

Michael Maus
Albert Einstein
ERROR
ERROR

Method only. You only have to write the method, not an entire program.

Error processing If the parameter is null, or if there is no ", ", return the string "ERROR".

Advertisement


DMCA.com