A Letter to Yourself

Write a program that displays your name and address on the screen as if it were a letter. Your output should look something like that below.

|                                                    #### |
|                                                    #### |
|                                                    #### |
|                                                         |
|                                                         |
|                              Bill Gates                 |
|                              1 Microsoft Way            |
|                              Redmond, WA 98104          |
|                                                         |

Note that your program should not display Bill Gates' address; use your own name and address.

Common Student Questions

Does my letter have to look exactly like yours?
No, but it does have to look roughly like a letter, including the box around the outside and the stamp.
Do I have to use my real address?
Of course not. But make sure your fake address takes up three lines.
How to I get a | to show up on the screen?
The | character is called a "pipe". Assuming you are using a normal US keyboard, it is Shift + backslash (\). The backslash key is usually located between the Backspace and Enter keys.
Why doesn't my letter line up when I run the program?!? Everything looks perfect in the code!

You probably used a mixture of tabs and spaces between the quotes in your println() statements. Many text editors / IDEs will only move the cursor 4 spaces when you press TAB. But when your program runs, any tabs embedded inside the quotes will take up 8 spaces, not 4. If you delete ALL the tabs between the quotes and replace them with spaces, things should look the same in your code and when you run the program.

(Most good text editors have an option to show visible whitespace, which can make it easier to fix this. For example, JCreator has a "Show Whitespace" option in the "View" menu, which will display spaces in your code with a small dot like and will display tabs with a little double bracket like ».)

©2014 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License