write a program that displays the following information, each on a separate line:

  • your name
  • your address, with city, state and ZIP
  • your telephone number
    your college major

    Although these items should be displayed on separate output lines, use only a single println statement in your program.

Recommended Answers

All 4 Replies

So something like this?

public class HelloWorld{

    public static String newline = System.getProperty("line.separator");
     public static void main(String []args){
        String me = "your name" + newline
                            +"your address" + newline
                            +"city, state and ZIP" + newline
                            +"your telephone number" + newline
                            +"your college major";
        System.out.println(me);
     }
}
commented: Genius. +14

I've a horrible feeling that that was all he was asking for (although a simple \n would have been sufficient).

Yash : we don't do people's homework for them, but we will help people to do it themselves. It's up to you.

It's been kicked around if \n would do. Think of other OSes and this covers them all. Just in case. So much left unasked by Yash. Seems too much like Hello World with well, what you see.

Something I've seen forever is poor specs. Seems odd that you would want just to print out one item like that.

The common complaint from users. "It's just what I asked for but not what I wanted."

commented: "Written to spec!" +7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.