Results 1 to 10 of 10
  1. #1
    luckyva is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Question Staircase printer using VI on MAC?

    Does anyone have the code for the following?:

    Staircase printer using VI on MAC?-screen-shot-2012-01-19-1.04.00-pm.png

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

    Default Re: Staircase printer using VI on MAC?

    I know how to create something like this by creating a Java program, but not by using VI on a Mac.

  3. #3
    luckyva is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Default Re: Staircase printer using VI on MAC?

    Yes, it should be a Java Code? Starting with: public class Stairs( or what ever i name it), public static void main(String[] args) below that then, the rest of the code.

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

    Default Re: Staircase printer using VI on MAC?

    Quote Originally Posted by luckyva View Post
    Yes, it should be a Java Code? Starting with: public class Stairs( or what ever i name it), public static void main(String[] args) below that then, the rest of the code.
    OK, can you show us what you've done so far, and then indicate any specific questions you may have regarding your code?

  5. #5
    luckyva is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Default Re: Staircase printer using VI on MAC?

    Sure! for the code I used a short cut by typing \d after each line. For example:
    public class Stairs
    {
    public static void main(String[] args)
    {
    System.out.println(" +---+\n | |\n +---+---+\n | | |\n +---+---+---+\n | | | |\n+---+---+---+---+\n| | | | |\n+---+---+---+---+\n");
    }
    }

    The staircase printed out great; however, I would like to know the long way to do this.

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

    Default Re: Staircase printer using VI on MAC?

    You'll want to experiment using for loops. The specifics you'll be able to figure out yourself with some experimentation -- the key is not to give up, to keep trying. Then if you get stuck come on back with more of your code.

  7. #7
    luckyva is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Default Re: Staircase printer using VI on MAC?

    Ok I made the Staircase with the below code. Is this too much? Can I consolidate? It printed out just fine. It just seems like a lot of work for a simple staircase.


    public class StairsLongP14 {
    public static void main(String[] args) {
    writeline1();
    writeline2();
    writeline3();
    writeline4();
    writeline5();
    writeline6();
    writeline7();
    writeline8();
    writeline9();
    }

    public static void writeline1() {
    for (int i = 1; i <= 1; i++) {
    System.out.print(" +---+");
    }
    System.out.println();
    }

    public static void writeline2() {
    for (int i = 1; i <= 1; i++) {
    System.out.print(" | |");
    } System.out.println();
    }

    public static void writeline3() {
    for (int i = 1; i <= 1; i++) {
    System.out.print(" +---+---+");
    }
    System.out.println();
    }
    public static void writeline4() {
    for (int i = 1; i <= 1; i++) {
    System.out.print(" | | |");
    }
    System.out.println();
    }
    public static void writeline5() {
    for (int i = 1; i <= 1; i++) {
    System.out.print(" +---+---+---+");
    }
    System.out.println();
    }
    public static void writeline6() {
    for (int i = 1; i <= 1; i++) {
    System.out.print(" | | | |");
    }
    System.out.println();
    }
    public static void writeline7() {
    for (int i = 1; i <= 1; i++) {
    System.out.print("+---+---+---+---+");
    }
    System.out.println();
    }
    public static void writeline8() {
    for (int i = 1; i <= 1; i++) {
    System.out.print("| | | | |");
    }
    System.out.println();
    }
    public static void writeline9() {
    for (int i = 1; i <= 1; i++) {
    System.out.print("+---+---+---+---+");
    }
    System.out.println();
    }




    }

  8. #8
    luckyva is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Default Re: Staircase printer using VI on MAC?

    Here is the result. Any Feedback? Staircase printer using VI on MAC?-screen-shot-2012-01-20-8.41.21-pm.png

  9. #9
    skyflygirl11 is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Re: Staircase printer using VI on MAC?

    I have written...but it is backwards!... any help on how to turn the direction above?

  10. #10
    skyflygirl11 is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Re: Staircase printer using VI on MAC?

    Can you show the key to having the staircase the right direction

Similar Threads

  1. Need help with POS printer
    By bkirt in forum Java 2D
    Replies: 13
    Last Post: 08-29-2010, 11:11 PM
  2. Replies: 2
    Last Post: 02-20-2009, 07:25 AM
  3. jsp and printer
    By mohammedsiddig in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 08-25-2008, 04:57 PM
  4. Specifying a Network Printer in Printer Servlet
    By shapez in forum New To Java
    Replies: 0
    Last Post: 03-06-2008, 03:21 PM
  5. Replies: 0
    Last Post: 08-09-2007, 06: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
  •