Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. #1
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Displaying blocked letters?

    Hello,

    I'm new to Java and for one of my first programs that I am writing in java that displays a message with my name is blocked letters. There is supposed to be 5 print statements. Can anyone help me figure out what these are?

    Thanks,

    banabb89

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Displaying blocked letters?

    Take a piece of paper ruled into squares (like the exercise books highschool kids use for maths in my locale). Write the letters of your name with X's: be creative, but keep to the first 5 lines.

    Those 5 lines will be the strings you should print with the empty squares represented by a space character.

    Consult your textbook or notes for how to set up a class and examples of using println().

    Post what you come up with if you get stuck.

  3. #3
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Displaying blocked letters?

    Does this look like what it should be?

    Java Code:
    public class Hello {
    	public static void main (String[] args) {
    		System.out.println
    		(" B B B    E E E E  N       N    N       N    A A    B B B   B B B
    		   B     B  E        N N     N    N N     N  A     A  B    B  B    B
    		   B B B    E E E E  N   N   N    N   N   N  A A A A  B B B   B B B
    		   B     B  E        N     N N    N     N N  A     A  B    B  B    B
    		   B B B    E E E E  N      NN    N       N  A     A  B B B   B B B  "); 
    	}
    }
    Last edited by Fubarable; 08-31-2012 at 03:47 AM. Reason: code tags added

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,785
    Rep Power
    7

    Default Re: Displaying blocked letters?

    Quote Originally Posted by banabb89 View Post
    Does this look like what it should be?
    Why ask us?

    Does it compile?
    Does it run?
    Does it produce correct output?
    Does it satisfy all requirements? In your first post you mentioned 5 print statements.

  6. #6
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Displaying blocked letters?

    sorry there's a lot of syntax errors and I'm trying to figure out what they are. Can either of you help me find them?

  7. #7
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,785
    Rep Power
    7

    Default Re: Displaying blocked letters?

    Post the FULL error message(s) and indicate on which line they occur.

  8. #8
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Displaying blocked letters?

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\BENJAMIN>J:

    J:\>cd java

    J:\java>dir
    Volume in drive J has no label.
    Volume Serial Number is 4300-E250

    Directory of J:\java

    08/26/2012 11:33 PM <DIR> .
    08/26/2012 11:33 PM <DIR> ..
    08/29/2012 10:36 AM 115 Hello.java
    08/27/2012 10:55 AM 419 Hello.class
    08/27/2012 11:06 AM 221 Hello.java.zip
    08/29/2012 10:29 AM 236 GUIDemo1.java
    08/29/2012 10:18 AM 392 GUIDemo1.class
    08/30/2012 08:56 PM 456 Name.java
    6 File(s) 1,839 bytes
    2 Dir(s) 520,265,728 bytes free

    J:\java>javac Name.java
    Name.java:4: error: unclosed string literal
    (" B B B E E E E N N N N A A B B B B
    B B
    ^
    Name.java:4: error: ';' expected
    (" B B B E E E E N N N N A A B B B B
    B B

    ^
    Name.java:5: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:5: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:5: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:5: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:5: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:5: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:5: error: ';' expected
    B B E N N N N N N A A B B B
    B

    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B
    ^
    Name.java:6: error: ';' expected
    B B B E E E E N N N N N N A A A A B B B B
    B B

    ^
    Name.java:7: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:7: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:7: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:7: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:7: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:7: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:7: error: ';' expected
    B B E N N N N N N A A B B B
    B
    ^
    Name.java:7: error: ';' expected
    B B E N N N N N N A A B B B
    B

    ^
    Name.java:8: error: ';' expected
    B B B E E E E N NN N N A A B B B B
    B B ");
    ^
    Name.java:8: error: ';' expected
    B B B E E E E N NN N N A A B B B B
    B B ");
    ^
    Name.java:8: error: ';' expected
    B B B E E E E N NN N N A A B B B B
    B B ");
    ^
    Name.java:8: error: ';' expected
    B B B E E E E N NN N N A A B B B B
    B B ");
    ^
    Name.java:8: error: ';' expected
    B B B E E E E N NN N N A A B B B B
    B B ");
    ^
    Name.java:8: error: ';' expected
    B B B E E E E N NN N N A A B B B B
    B B ");
    ^
    Name.java:8: error: ';' expected
    B B B E E E E N NN N N A A B B B B
    B B ");
    ^
    Name.java:8: error: ';' expected
    B B B E E E E N NN N N A A B B B B
    B B ");
    ^
    Name.java:8: error: ';' expected
    B B B E E E E N NN N N A A B B B B
    B B ");

    ^
    Name.java:8: error: unclosed string literal
    B B B E E E E N NN N N A A B B B B
    B B ");

    ^
    Name.java:8: error: not a statement
    B B B E E E E N NN N N A A B B B B
    B B ");

    ^
    39 errors

  9. #9
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Displaying blocked letters?

    The class name "Name" is now the same as the file name. I changed it.

  10. #10
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,785
    Rep Power
    7

    Default Re: Displaying blocked letters?

    You cannot create Strings like that.
    Java Code:
    String s = "This text is on one line" +
                  "This text is on another line";

  11. #11
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,785
    Rep Power
    7

    Default Re: Displaying blocked letters?

    Note that it still not do what you want unless you explicitly add new lines.

  12. #12
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Displaying blocked letters?

    Does that go in the brackets next to string and do you have to specify the line number?

  13. #13
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,785
    Rep Power
    7

    Default Re: Displaying blocked letters?

    My code above was a simple example of placing text on more than one line. You must close each substring and concatenate them together. However you are concentrating on the wrong issue. Once again I point you back to your original post where you mentioned FIVE print statements.

  14. #14
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Displaying blocked letters?

    Ok. I need 5 print statements. But where do they go? And does it still look like (String[] args) { along with what you put?

  15. #15
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Displaying blocked letters?

    Can you post what the whole thing would look like along with what I posted?

  16. #16
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,785
    Rep Power
    7

    Default Re: Displaying blocked letters?

    What has the args parameter got to do with it? Are you planning on passing information into your program?

    The solution to your problem is fairly obvious. You currently have ONE print statement trying to print FIVE lines. You need FIVE statements printing FIVE lines. Surely you can work that out.

  17. #17
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Displaying blocked letters?

    I'm sorry I'm new to this so I just want to know exactly how to end a line and start a new line of text

  18. #18
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,785
    Rep Power
    7

    Default Re: Displaying blocked letters?

    ARE YOU LISTENING?

    Stop worrying about how to stop ending a line of text and continuing it on the next line. All you have to do is write FIVE print statements, one after the other and each print statement prints ONE line of text.

  19. #19
    banabb89 is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Displaying blocked letters?

    What is the print statement? Could you tell me please? I'm trying to understand.

  20. #20
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,785
    Rep Power
    7

    Default Re: Displaying blocked letters?

    :headdesk:

    1. Write a program to display "Hello"
    2. Modify the program to display "Hello" five times, each word on a new line:
    Hello
    Hello
    Hello
    Hello
    Hello
    3. Modify the program to display your name.

    That's all from me!

Page 1 of 2 12 LastLast

Similar Threads

  1. Threads Blocked
    By alexj001 in forum Advanced Java
    Replies: 0
    Last Post: 01-03-2012, 09:39 AM
  2. apple blocked by UAC ?!?
    By newbie_jar in forum Java Applets
    Replies: 1
    Last Post: 11-15-2011, 04:10 PM
  3. Gui Blocked after selected a Jcheckbox
    By simplo in forum AWT / Swing
    Replies: 2
    Last Post: 09-03-2010, 10:04 AM
  4. Replies: 2
    Last Post: 03-19-2010, 08:24 AM
  5. blocked between server and clients
    By ibtehal in forum Networking
    Replies: 6
    Last Post: 07-17-2008, 12:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •