Help Print ASCII Pattern

Hey I'm writing a simple little program that creates a method call printPatterns() that when called should print out two simple patterns:
#However, I'm not exactly sure how to call it in the main method. Here's the code thus far:
import java.io.*;
import java.util.Scanner;
import java.lang.String.*;
public class Patterns {
    public void printPatterns()
    int row=1, j=1;
    char OUTPUT='#';
    System.out.println();
    for (row = 1; row <= 8; row++)
        for (j = 1; j <= row - 1; j++)
            System.out.print(" ");
        for (j = 1; j <= 9 - row; j++)
            System.out.print(OUTPUT);
    System.out.println();
    System.out.println();
    for (row = 1; row <= 8; row++)
        for (j = 1; j <= 9 - row; j++)
            System.out.print(OUTPUT);
    System.out.println();
    System.out.println();
    public void main (String[] args)
        printPatterns test = new printPatterns();
        System.out.print(test);
}

Simply create an object and call its methods.
public class Fubar
    public void foo()
        System.out.println("Foo");
    public static void main(String[] args)
        Fubar myFubar = new Fubar();  // create an object myFubar
        myFubar.foo();                // and call its method foo
}edit: is this spooky or what??? I created my Fubar / foo before I saw the previous post.
Edited by: Encephalopathic on Mar 26, 2008 8:05 PM

Similar Messages

  • Problem printing line pattern at diagonal

    Hello there. I'm having a problem printing a pattern fill that is stripes, then rotated so it is diagonal. It looks fine in illustrator but when it prints it comes out choppy/pixelated. I've attached a scan of the print to show you what I mean.
    Also, when printing small dashed lines they dont come out clean, some are missing or connected and it just looks strange....
    Please help! thanks!

    The illustration printed fine as a pdf, but thats kind of a biotch though!

  • Caesar Cipher and non printing ascii

    I am writing a program to implements the caesar cipher. For the program I am using ASCII code so my encryption algorithm is:
    c = (p + k) mod 128
    The only problem is, is that depending on the characters being encrypted and depending on the key I use some of the characters are encrypted to non-printing ascii characters such as 'del'.
    So my code reads in the plain text from a file converts each character to ascii, encrypts each character using the key. It then writes the encrypted ascii values to a file as text (i.e. the character equivalent of the ascii).
    If I do then encounter a non-printing ascii value it is written to the file as a square shape. Is there any way I can get around this?
    Thanks for your help on the matter.
    Wallace

    Modify your encryption function so that it only covers those ASCII values that print, i.e. you need to implement the mod and + function yourself so that only good ASCII characters are considered.

  • Please help me install Pattern Maker?

    Hi,
    At this url:
    http://www.adobe.com/support/downloads/thankyou.jsp?ftpID=4687&fileID=4377
    I am trying to download the plugin:
    CS5_Optional_PlugIns_Installer.dmg
    The files included are:
    CS5 Optional Extension Plug-Ins.mxp
    and
    CS5 Optional Plugins.mxp
    When I attempt to install either of these two files, I get the following error message:
    I’m attempting to place the installs into the Applications> Photoshop CS5 > Plugins > Optional Plugins
    I'm on a Mac OS 10.6.5
    What am I doing wrong?
    Thank you so much in advance.
    Linda

    Hi Linda,
    Sorry if I confused, but I just want to make sure that you don't have all the Optional Extensions installed and enabled (as fallout from trying to get Pattern Maker working). There are two .mxp files and you mentioned trying to install both of them. I haven't seen the actual error you get, so to be safe, I'm suggesting that you make sure to disable all the Optional Extensions (and likely all the optional plug-ins that you don't need too). The installers are/were all or nothing (I'm not sure if the installer .mxp for Optional Extensions has been removed yet).
    The quickest way to uninstall is using the CS5 Service Manager application (IF it is working correctly). The quickest way to tell if they are installed is probably to look in this folder: Adobe Photoshop CS5/Plug-Ins/Extensions.
    There should only be 5 there by default: Enable Async IO, FastCore, MMXCore, MultiProcessor Support, and ScriptingSupport.
    Let me know if you still have  questions,
    regards,
    steve
    Linda1234567 wrote:
    Okay, now I have no idea what you're talking about!  pattern maker is working.  Can't I just leave well enough alone?:-)Linda
    Date: Wed, 29 Dec 2010 17:37:09 -0700
    From: [email protected]
    To: [email protected]
    Subject: Photoshop Macintosh Please help me install Pattern Maker?
    Hi Linda,
    If you installed the Optional Extensions Plug-Ins.mxp you'll want to uninstall all of them (or disable them and only enable individual ones that are needed). To uninstall, use the CS5 Extension Manager. To disable them, individually rename each with a tilde(~) as the first character.
    regards,
    steve
    >

  • Unable to print ASCII codes

    Hello,
    I am facing a problem in printing ASCII code between 128 and 159. these codes are displayed as '?'. All the other codes are printed correctly. Please let me know the reason behind this.
    Given below is the code for the same
    class Codes
         public static void main(String args[])
              short i = 165;
              for (i=0; i<=256;i+=5)
                   System.out.println(i+" "+(byte)i+" "+(i+1)+" "+(byte)(i+1)+" "+(i+2)+" "+(byte)(i+2)+" "+(i+3)+" "+(byte)(i+3)+" "+(i+4)+" "+(byte)(i+4));
    Waiting for a quick reply
    rgds,
    Sameer

    1. What are the chars you are talking about? As already mentioned, they are control chars in unicode. What character encoding would you like to use, or in other words, what characters would you like to have for those bytes?
    2. The character encoding of the dos console (Cp850 on the windozes I've used) is different from the system's default encoding (Cp1252, IIRC). This will cause problems if you want to print out text having non-ascii characters. For example System.out.println("&Aring;&Auml;&Ouml;") should print out the last three letters of the finnish alphabet but it prints something else instead. But if you write the text to a file it comes out as it should.
    Another character encoding can be used by wrapping an OutputStreamWriter around System.out:
    OutputStreamWriter osw = new OutputStreamWriter(System.out, "Cp850");
    PrintWriter out = new PrintWriter(osw, true);
    out.println("&Aring;&Auml;&Ouml;");
    Similarly, the input read through the standard inputstream in dos (the keyboard input or redirection using "<") is in another encoding and needs to be converted.

  • Processsing non-printing ASCII characters using ABAP

    Hi All,
    I would like to process a GUI field input that contains a non-printing ASCII character. It is actually from barcode being read into a GUI field that is then picked up by an ABAP program e.g. in readable format looks like this: 123456789 but actually contains a non-printing ASCII character (ASCII char 29) used as a data separator e.g. 1234<sep>567<sep>89.
    I would like to parse the input using ABAP at the non-printing ASCII character so that I have 3 variables A=1234 & B=567 & C=89.
    How should I best tackle this?
    Cheers,
    N.

    Pls check this...
    DATA: hx29 type x value '29'.
    data : wa_hx29(1).
    data : wa_str(30) type c.
    data : wa_str1(10),wa_str2(10),wa_str3(7).
    wa_hx29 = hx29.
    split wa_str at wa_hx29 into wa_str1 wa_str2 wa_str3.

  • Need help in finding patterns and there counts

    Hi All,
    I need help in finding patterns as well as number of occurrences of those patterns in a table's column's data.
    Consider sample data - one row's column from a table:
    "S-S-S-P-S-B-S-S-C-S-P"
    My requirement is:
    I should get all the patterns that are followed by 'S'.
    Example: for the above given data the patterns and counts are
    SS - count is 3
    SP - count is 2
    SB - count is 1
    SS - count is 1
    There is one more condition for the above requirement:
    If 'S' is followed by 'A', then 'SA' should not be considered as a pattern. The pattern should stretch until a non 'A' character is found.
    Consider sample data for the above case:
    "S-S-A-S-S-A-A-C-S-P-S-A"
    for the above given data the patterns and counts are
    SS - count is 2
    SP - count is 1
    SAS - count is 1
    SAAC - count is 1
    The data column is stored as VARCHAR2 type.
    I have Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    Thanks in advance,
    Girish G

    Hi, Girish,
    Girish G wrote:
    Hi All,
    I need help in finding patterns as well as number of occurrences of those patterns in a table's column's data.
    Consider sample data - one row's column from a table:
    "S-S-S-P-S-B-S-S-C-S-P"
    My requirement is:
    I should get all the patterns that are followed by 'S'.Do you mean "I should get all patterns that *start with* 'S'"?
    Example: for the above given data the patterns and counts are
    SS - count is 3
    SP - count is 2
    SB - count is 1
    SS - count is 1Why are there two rows of output for 'SS'? What does the second one, with count=1, mean?
    There is one more condition for the above requirement:
    If 'S' is followed by 'A', then 'SA' should not be considered as a pattern. The pattern should stretch until a non 'A' character is found.
    Consider sample data for the above case:
    "S-S-A-S-S-A-A-C-S-P-S-A"
    for the above given data the patterns and counts are
    SS - count is 2
    SP - count is 1
    SAS - count is 1
    SAAC - count is 1
    The data column is stored as VARCHAR2 type.
    I have Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit ProductionThanks; the version information is very helpful.
    Thanks in advance,
    Girish GWhenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    For example, your sample data might be:
    CREATE TABLE     table_x
    (       x_id     NUMBER     PRIMARY KEY
    ,     txt     VARCHAR2 (30)
    INSERT INTO table_x (x_id, txt) VALUES (1, 'S-S-S-P-S-B-S-S-C-S-P');
    INSERT INTO table_x (x_id, txt) VALUES (2, 'S-S-A-S-S-A-A-C-S-P-S-A');and the results you want from that data might be:
    X_ID TXT                       PATTERN                          CNT
       1 S-S-S-P-S-B-S-S-C-S-P     SB                                 1
       1 S-S-S-P-S-B-S-S-C-S-P     SC                                 1
       1 S-S-S-P-S-B-S-S-C-S-P     SP                                 2
       1 S-S-S-P-S-B-S-S-C-S-P     SS                                 3
       2 S-S-A-S-S-A-A-C-S-P-S-A   SAAC                               1
       2 S-S-A-S-S-A-A-C-S-P-S-A   SAS                                1
       2 S-S-A-S-S-A-A-C-S-P-S-A   SP                                 1
       2 S-S-A-S-S-A-A-C-S-P-S-A   SS                                 2(This corresponds to what you posted, except that there is only one output row for 'SS' when x_id=1.)
    One way to get those results in Oracle 11 is:
    WITH   got_s_cnt    AS
         SELECT     x_id, txt
         ,     REGEXP_COUNT (txt, 'S')     AS s_cnt
         FROM     table_x
    ,     cntr          AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= (
                                   SELECT  MAX (s_cnt)
                             FROM    got_s_cnt
    ,     got_pattern     AS
         SELECT     s.x_id
         ,     s.txt
         ,     c.n
         ,     REGEXP_SUBSTR ( REPLACE ( SUBSTR ( txt
                                                 , INSTR (s.txt, 'S', 1, c.n)
                         , 'SA*[^A]'
                            )       AS pattern
         FROM    got_s_cnt  s
         JOIN     cntr        c  ON  c.n  <= s.s_cnt
    SELECT       x_id
    ,       txt
    ,       pattern
    ,       COUNT (*)     AS cnt
    FROM       got_pattern
    WHERE       pattern     IS NOT NULL
    GROUP BY  x_id
    ,            txt
    ,       pattern
    ORDER BY  x_id
    ,            pattern
    ;At the heart of this query is the call to REGEXP_SUBSTR:
    REGEXP_SUBSTR ( x
               , 'SA*[^A]'
               )which is looking for:
    S     = the letter S
    A*     = the letter A, repeated 0 or more times
    [^A]     = anything except the letter A

  • Help with recursive function to print number patterns

    I'm sorry for having to ask for homework help - I'm badly stuck on this! Can someone give me a kick in the right direction with this?
    need a recursive function with a single positive int parameter n. the function should write (2^n - 1) integers and should be in the following pattern...
    n = 1, Output: 1
    n = 2, Output: 1 2 1
    n = 3, Output: 1 2 1 3 1 2 1
    n = 4, Output: 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
    n = 5, Output: 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
    function should valid for all positive integer values of n
    This was tagged as a 'short' problem...so it shouldnt take too much code...I am hung on on the following:
    *Do I keep track of the numbers printed, if so how?  I only have a single parameter to call with so I am confused as to how I could get an entire pattern without keeping track of the history
    *I had initially thought it would be necessary to cut it in half and do the 2nd half backwards (ie: for n=3, I would take care of the 1 2 1 - then 3 - then 1 2 1...but even then it seems like I could cut 1 2 1 in half the same way and therefor I should be able to do ALL of it in single parts...
    Can someone veer me in the right direction here? I'm really lost with this.

    This was tagged as a 'short' problem...so it shouldnt
    take too much code...Yeah, the method body could be done in a few lines.
    I am hung on on the following:
    *Do I keep track of the numbers printed, if so how?Not explicitly. Use the call stack. That is, use the fact that when you're recursing, the previous values of numbers are preserved in the previous method invocation.
    I only have a single parameter to call with so I am
    confused as to how I could get an entire pattern
    without keeping track of the historyYou don't have to store anything across method invocations.
    I had initially thought it would be necessary to cut
    it in half and do the 2nd half backwards (ie: for
    n=3, I would take care of the 1 2 1 - then 3 - then 1
    2 1...but even then it seems like I could cut 1 2 1
    in half the same way and therefor I should be able to
    do ALL of it in single parts...No, it's MUCH simpler than that. It's easier than yo uthink.
    Can someone veer me in the right direction here? I'm
    really lost with this.Try this simpler version of the problem:
    Write a recursive method that creates this output:
    n = 1: 1
    n = 2: 1 2
    n = 3: 1 2 3
    And try this simpler version:
    n = 1: 1
    n = 2: 2 1
    n = 3: 3 2 1

  • Help me print ASCII table to screen

    I want to output all characters from 0 to 255 to screen, but some characters display invalid (it return character "?" ). Can you help me ? What's charSet I have to use ???
    Thank you very much.
    LMHUNG

    Some of the ASCII codes are for 'non-printable' characters
    e.g. carriage-return, line feed, etc.
    So you won't be able to print those ones.

  • Reader 8.1.2 prints ASCII charactors

    Just installed Reader 8.1.2 on my new Vista 32Bit Home Premium. I can print DOC from Office 2007 and Notepad OK to my Epson RX500 but PDF's print in what looks like ASCII gobbledegook. Is there any program interaction issue's?? HELP!!

    Johndes,
    Beginning with OS X 10.5, some of us could not print a PDF from the Adobe Reader program. Our printers would be put on "pause" rather than printing the document.
    The expectation was that when Acrobat Reader was upgraded to v. 8.1.2, that Adobe would have that anomaly fixed. The beginning of this thread starts at the point where v 8.1.2 was released, and it was recognized that there was no fix, and our printers would continue to pause rather than print.
    You are correct that we could open and print PDFs from another program. I used PDFPen because Preview would also pause my printer. That doesn't change the fact that, for whatever reason, Adobe Reader was the only application which required this workaround to get a printed copy. And, that happened on every later version of OS X 10.5, including 10.5.1.
    I resolved the problem with an ERASE AND INSTALL of Leopard. I don't know where the problem originated, but I can now print directly from Adobe Reader. To me, it was worth that effort.

  • Help required with Pattern (Regex use)

    Hello everybody !!
    I'd like to use the Regex Package to find the following Pattern in the following expression:
    PATTERN = prim*bbb
    INPUT = xxx prim yyy xxx prim aaa bbb ddd
    and I would like to obtain two results in the same matching:
    1=> prim yyy xxx prim aaa bbb
    2=> prim aaa bbb
    When I try I obtain just the first one as you can see below:
    Current REGEX is: prim.*bbb
    Current INPUT is: xxx prim yyy xxx prim aaa bbb ddd
    Nombre de groupe =0
    I found the text "prim yyy xxx prim aaa bbb" starting at index 4 and ending at i
    ndex 29.
    Could you help me to cope with regex in order to define such Pattern and obtain these results.
    Thanks a lot !!

    Ok here is something that I wrote up.
    Keep in mind I do not have java 1.4 installed so I could not compile nor test this code.
    It seems like a crazy way to do it , but I can't think of any other way at this time.
    Basically find the String, Trim off the prim and bbb and try to find it again, repeat untill there is not a gap between prim and bbb or maybee a gap of only 1 , was not sure what your exit point would be.
    Hopefully maybee this will help , or not confuse. :-)
    while(matcher.find()) {
    String matchedString = matcher.group();
    System.out.println("I found the text \"" + matcher.group()
    + "\" starting at index " + matcher.start()
    + " and ending at index " + matcher.end() + ".");
    // call this method to search for inner matches
    findInnerMatch(matchedString);
    public void findInnerMatch(String matchedString,String regex) {
    // get the string between prim and bbb *** check index's etc...
    String innerString = matchedString.substring(matchedString.indexOf("prim"),matchedString.lastIndexOf("bbb")-1);
    // make a new pattern with same regular expression
    Pattern pattern = Pattern.compile(regex);
    // make a new matcher with the inner string portion
    Matcher matcher = pattern.matcher(innerString);
    if (matcher.find()) {
    // if it finds a match print it out
    System.out.print("Found: " + innerString);
    // see if there is a gap between prim and bbb *** check index's etc..
    while (innerString.indexOf("prim") < innerString.lastIndexOf("bbb")) {
    // if more check again another occurance
    findInnerMatch(innerString);
    }

  • Printing ascii value in JLabel

    dear seniors...
    i couldnt able to print an ASCII ( e.g : 31-'&#9660;' & 30-'&#9650;' in a JLabel).
    any help regarding this will be very much appreciated.
    thanx in advance.
    -Munas.

    If your default fonts are OK then the following shows how to get the arrows you want.
    import javax.swing.*;
    import java.awt.*;
    public class Test20041222 extends JFrame
        public Test20041222()
            super("Arrow Test");
            JPanel panel = new JPanel(new GridLayout(0,1));
            panel.add(new JLabel("Up Arrow \u25b2"));
            panel.add(new JLabel("Down Arrow \u25bc"));
            getContentPane().add(panel);
            pack();
        public static void main(String[] args)
            new Test20041222().setVisible(true);
    }

  • Need helping printing to networked printers.

    I need help setting up network printers that have a code on them for each individual. There is no place to put a code so the printer will know who is printing what. I have installed 3 printers and they will not print, they just go to a paused mode and when you hit resume in reverts back to pause because it is looking for a code. I have tried it another way but it asks for a user name and password and all we have are codes. The workplace is using a windows based server and the copiers are listed as followed.
    Konica biz hub c450
    Sharp ar m700n
    sharp mx700n
    I need help to be able to print from my mac. I also have parallels running with xp installed and all the printers are installed on that side and printing fine. Hopefully someone can help me out.
    Thanks in advance

    Hello and welcome to Apple Discussions.
    In order to provide the user with the ability to input a user code, the respective printer driver would have to provide the facility. If this feature did exist on a previous version of OS X, then you may have to check the vendors web site to see if there is a driver for 10.6.
    If you are not sure if the function was supported previously, then go through all the user menus for the driver. The function may be present but located in an unusual location. Or it could require an additional file (aka plugin) that could be missing from the driver installation or not compatible with 10.6.
    The other thing to note is that if you have the Mac's printing via a Windows queue, you will have to provide user credentials for SMB print queues. This is typically a Windows user account - not the Mac's account details. If you don't want to create accounts for the Mac users on the Windows server, then you can use LPD rather than SMB to connect to the Windows queues. This does require UNIX Printing Services to be enabled on the server.
    Pahu

  • Printing fill patterns with Acrobat 8 pro & reader

    When I export a freehand 8 or 11 drawing with colored fill
    patterns to pdf using export or distiller, it looks correct in
    Acrobat 8 professional and reader, but it doesn't print the fill
    patterns in color. They come out black & white. I don't wan to
    use a PS printer since most of the people I sned the pdfs to don't
    have postscript. This didn't happen with earlier versions of
    Acrobat. Any ideas to fix this problem?

    It would either be Acrobat or Reader, not Acrobat Reader (that went about after AA 5). Reader XI can be run with AA 8, but you may periodically have to tell it which to open a PDF with. Using both can mix up the OS as to which it should use. That is the main problem I am aware of. If you meant Acrobat XI, then there may be an issue with the print drivers. You may have to play some file name changes and such for Acrobat 8 before you install Acrobat XI if that is the case, but the name changes may cause other issues based on how you are using the software. If it is AA XI, I would check to be sure that this version is not compatible with your CAD before trying the 2 version route.

  • I need help printing with HP laserjet 2200 and OS 10.6

    I need help setting up my HP laserjet 2200 and OS 10.6 -- I've downloaded and installed all the software and still can't print.

    Hey jeo1951,
    If you haven't already, try running through the recommended steps in the following article:
    Mac 101: Printing (Mac OS X v10.6)
    http://support.apple.com/kb/HT3771
    It should help you set up your printer.
    Welcome to Apple Support Communities!
    All the best,
    Delgadoh

Maybe you are looking for