Results 1 to 12 of 12
  1. #1
    Join Date
    May 2002
    Posts
    91

    Urgent Help for EASY Java Programming ! Pay if Necessary !

    I need a simple script/program that run like this:

    Write a program Lab02.java to draw a squared pattern like this:
    D:\it1002>java Lab02
    > Give height: 12

    +-+-+-+-+-+-
    -+-+-+-+-+-+
    +-+-+-+-+-+-
    -+-+-+-+-+-+
    +-+-+-+-+-+-
    -+-+-+-+-+-+
    +-+-+-+-+-+-
    -+-+-+-+-+-+
    +-+-+-+-+-+-
    -+-+-+-+-+-+
    +-+-+-+-+-+-
    -+-+-+-+-+-+

    Anyone can help me ? Willing to pay to get it done. This is an assignment from my school, but can't seems to figure it out !

    Need it by Friday!!

  2. #2
    Join Date
    May 2002
    Location
    Scotland, UK
    Posts
    34

  3. #3
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    297
    use the for statement,

    something like..

    int number;

    number = readInt();

    for (int i = 0; i <=12;i++){
    System.out.println("-+-+-+-+-+-+");
    }


    or since very second line,,the output is different..you may want to halve the number then replace:

    System.out.println("-+-+-+-+-+-+");

    with
    System.out.println("-+-+-+-+-+-+\n+-+-+-+-+-+-");


    NOTE: this is not actual code..but it may help to guide you through it.
    Banner Design - Professional Designs - 24hr Turn-Around Guaranteed - 20DollarBanners.com

    Online Photo Editor
    Retouch or Add effects to your photos with 1 click

  4. #4
    Join Date
    May 2002
    Posts
    91
    Thanks for ya help, but the print must be ("+"),("-") and not ("-+-+-+-+-+-+"), and that is the tedious part.

    I had tried it for days without getting it right.



    Originally posted by Aplusmedia
    use the for statement,

    something like..

    int number;

    number = readInt();

    for (int i = 0; i <=12;i++){
    System.out.println("-+-+-+-+-+-+");
    }


    or since very second line,,the output is different..you may want to halve the number then replace:

    System.out.println("-+-+-+-+-+-+");

    with
    System.out.println("-+-+-+-+-+-+\n+-+-+-+-+-+-");


    NOTE: this is not actual code..but it may help to guide you through it.

  5. #5
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    297
    then use "while" and "for" and "if"

    int number;
    int line = number -1;
    number = readInt();

    while (line < number && > 0){
    for(int i = 0;i<=number;i++){
    if (i > 0) System.out.print("+")
    if (i > 0) System.out.print("-");
    }//end for
    line --;
    }//end while

    in the for loop...it'll print "+" and "-" until it reaches given number (12)
    all this will happen while number of line is greater than 0, it decrement everytime it has finish printing a complete line of -+-+-+

    this may not work exactly as you want..im just writing what ever comes in my head as i type. but you can play around...i think that code(psuedocode may work)

    if not..try kasamba.com
    Banner Design - Professional Designs - 24hr Turn-Around Guaranteed - 20DollarBanners.com

    Online Photo Editor
    Retouch or Add effects to your photos with 1 click

  6. #6
    Join Date
    May 2001
    Posts
    1,593
    Aplusmedia has been very helpful, but if you still need help, post the code you already have first, so we can pinpoint the problem for you.

    We can help, but we can't do your homework for you.

    Peter

  7. #7
    Join Date
    Oct 2001
    Location
    California, USA
    Posts
    1,316
    Guys-,
    not to rain on your parade, but obviously this is a lab assignement.

    You're not doing the guy -or his fellow students- any favour by giving him the solution in a nutshell.
    The goal of assignements is to use your acquired knowledge in a smart manner, hence helping you make progress.
    http://www.voilaweb.com - the Social Internet Toolbox.

  8. #8
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    297
    well...i didnt give him the code, what i given him is a starting point..where he can then try and solve it.
    Banner Design - Professional Designs - 24hr Turn-Around Guaranteed - 20DollarBanners.com

    Online Photo Editor
    Retouch or Add effects to your photos with 1 click

  9. #9
    Join Date
    Aug 2002
    Location
    Itapecerica da Serra
    Posts
    0
    You can do something like this:

    lines=12;
    for (int i=0; i<lines; i++){

  10. #10
    Join Date
    Aug 2002
    Location
    Itapecerica da Serra
    Posts
    0
    Try something like this:

    int lines=12;
    String symbol="-";
    StringBuffer sb = new StringBuffer();
    for (int x=0; i<lines; x++){
    for (int y=0; y<lines; y++){
    if (symbol.equals("-") symbol="+";
    else symbol="-";
    sb.append(symbol);
    }
    sb.append("\n");
    }
    System.out.println(sb.toString());
    }

  11. #11
    Join Date
    May 2001
    Posts
    1,593
    Magoo, it is not good for you to write code for him; he should learn on his own.

    Besides, the way you coded it is too complicated and not to the spirit of the original assignment.

    Peter

  12. #12
    Join Date
    Oct 2001
    Location
    California, USA
    Posts
    1,316
    I think, if Raydon did submit here what he has done so far, we would be more than happy to point out why it's not working.
    http://www.voilaweb.com - the Social Internet Toolbox.

Posting Permissions

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