Printing a 2d array in matrix format

Hi everyone- first time posting here... I'm an undergrad CS major at the Colorado School of Mines. I'm trying to write a metho that will print out a 2D array (3x3) in matrix form. Here is what I have:
public static void printArray(int[][]array3){
for (int i=0; i<array3.length; i++)
for (int j = 0; j<array3[0].length; j++) {
int count=0;
if (count % 3 ==0){
System.out.println(array3[i][j] + " ");
count++;
else{
System.out.print(array3[i][j] + " ");
count++;
All it does is list the elements of the array as follows.
Sample:
1, 2, 3 input array
prints:
1
2
3
Any help would be appreciated.

1 public static void printArray(int[][]array3){
2       for (int i=0; i<array3.length; i++)
3         for (int j = 0; j<array3[0].length; j++) {
4           int count=0;
5           if (count % 3 ==0){
6             System.out.println(array3[i][j] + " ");
7             count++;
8           }
9           else{
10             System.out.print(array3[i][j] + " ");
11             count++;
12           }
13         }
14     }Lets just run through it, step by step
-1
   i = Out of scope
   j = out of scope
   count = out of scope
-2
   i = 0
   j = out of scope
   count = out of scope
-3
   i = 0
   j = 0
   count = out of scope
-4
   i = 0
   j = 0
   count = 0
-5
   i = 0
   j = 0
   count = 0
   (count % 3 ) = 0
-6
   i = 0
   j = 0
   count = 0
   print 1<new line>
-7
   i = 0
   j = 0
   count = 1
-8
   i = 0
   j = 0
   count = 1
-13
   i = 0
   j = 0
   count = out of scope
-3
   i = 0
   j = 1
   count = out of scope
-4
   i = 0
   j = 1
   count = 0Hint: You don't need count, you have a counter (i*3)+j, and even a counter than just goes between 0 to 2.

Similar Messages

  • Combine Columns From Separate Arrays Into One Formatted Table

    What I'm trying to do is make two WMI queries with 2 different classes for a list of machines and then patch the columns together into one single array that is formatted as a table with columns and rows. I seem to keep banging my head against the wall and
    I can't help but feel that the answer is simple. I can certainly create an array that contains all 3 columns (such as in the commented out part) but no matter which angle I go at it, it always seems to end up as all the data in one single row in each column
    rather than a nicely formatted table. I've even tried constructing separate custom objects and adding the different objects to the array but that's obviously not working. Below is the code of the last thing I tried. I need someone to bash it to death and tell
    me the (most likely obvious) thing that I'm doing wrong. Thanks!
    $failedos = @()
    $failedcs = @()
    $ccs = get-adcomputer -property operatingsystem -filter {name -like "*-CC*"} | select name | sort name
    $cs = foreach ($cc in $ccs){$cc.name | % {if ($c=get-wmiobject -computername $cc.name -class win32_computersystem -ErrorAction SilentlyContinue){$c | select @{Name="Name";Expression={$_.Name}}, @{Name="Model";Expression={$_.Model}}} else {$failedcs += "$_"}}}
    $os = foreach ($cc in $ccs){$cc.name | % {if ($o=get-wmiobject -computername $cc.name -class win32_operatingsystem -ErrorAction SilentlyContinue){$o | select @{Name="OperatingSystem";Expression={$_.caption}}} else {$failedos += "$_"}}}
    #[array]$osprops = @{'Name'=$cs.Name;'Model'=$cs.Model;'OperatingSystem'=$os.OperatingSystem}
    $result = @()
    Foreach ($Line in $cs) {
    $MyCustomObject = New-Object -TypeName PSObject
    Add-Member -InputObject $MyCustomObject -MemberType NoteProperty -Name "Name" -Value $Line.name -Force
    Add-Member -InputObject $MyCustomObject -MemberType NoteProperty -Name "Model" -Value $Line.Model -Force
    $result += $MyCustomObject
    foreach ($Line2 in $os) {
    $MyCustomObject2 = New-Object -TypeName PSObject
    Add-Member -InputObject $MyCustomObject2 -MemberType NoteProperty -Name "OperatingSystem" -Value $Line2.OperatingSystem -Force
    $result += $MyCustomObject2

    Any help?
    $ccs = get-adcomputer -property operatingsystem -filter {name -like "*-CC*"} |
    select -ExpandProperty name | sort
    $Result =
    Foreach ($CC in $CCs)
    $Object =
    New-Object PSObject -Property @{ Name = $CC
    Model = 'Failed'
    OperatingSystem = 'Failed'
    Try {
    $Object.Model =
    get-wmiobject -computername $CC -class win32_computersystem -ErrorAction Stop |
    select -ExpandProperty Model
    $Object.OperatingSystem =
    get-wmiobject -computername $CC -class win32_operatingsystem -ErrorAction Stop |
    select -ExpandProperty Caption
    Catch{}
    Finally { $Object }
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • How can I print a pages document in book format ..order?

    How can I print a pages document in book format ..order?

    This is usually a function of the driver you're using. Have you looked in the various PDEs for black and white or grayscale? What kind of printer are you using?

  • Unable to print xml publisher report in excel format in R12

    Hi All,
    We are unable to print xml publisher report in excel format in R12. We were able to see the excel output but it's printing junk characters while printing and it's printing without any issue with PDF format.
    Please let me know how to fix this issue.
    Thanks,
    Raja

    Hi Raja,
    I presume you have gone through the debugging process of testing your template locally first to get the expected result.....
    If yes, this note might probably be helpful "Changing Output Format to RTF or Excel in XML Publisher Request Does Not Display Output Correctly (Doc ID 404512.1)"
    Good Luck,
    Lamine Balde

  • How to edit & print a document created in "Pages format?

    Hoiw to edit & print a document created in "Pages format?

    The same way that you would do it for any application, print menu or export menu.

  • Error The File "Print.ai" is in an unkown format and cannot be opened adobe Ilustrator 5.5

    I am getting an error The File "Print.ai" is in an unkown format and cannot be opened adobe Ilustrator 5.5 on Mac OX 10.10.2 but was also the same in Mac Mavericks. any thoughts?

    d,
    In addition to what Larry said, there is a number of levels you can try for general issues, described in the following list. 1) and 2) are the easy ones, 3) is the basic preference file (irreversible procedure), 4) is the whole preferences folder (reversible and more thorough, needed for some issues), 6) is the full ultimate solution, 5) can be skipped in this case.
    The following is a general list of things you may try when the issue is not in a specific file, and when it is not caused by issues with opening a file from external media, see below. You may have tried/done some of them already; 1) and 2) are the easy ones for temporary strangenesses, and 3) and 4) are specifically aimed at possibly corrupt preferences); 5) is a list in itself, and 6) is the last resort.
    If possible/applicable, you should save current artwork first, of course.
    1) Close down Illy and open again;
    2) Restart the computer (you may do that up to at least 5 times);
    3) Close down Illy and press Ctrl+Alt+Shift/Cmd+Option+Shift during startup (easy but irreversible);
    4) Move the folder (follow the link with that name) with Illy closed (more tedious but also more thorough and reversible), for CS3 - CC you may find the folder here:
    https://helpx.adobe.com/illustrator/kb/preference-file-location-illustrator.html
    5) Look through and try out the relevant among the Other options (follow the link with that name, Item 7) is a list of usual suspects among other applications that may disturb and confuse Illy, Item 15) applies to CC, CS6, and maybe CS5);
    Even more seriously, you may:
    6) Uninstall (ticking the box to delete the preferences), run the Cleaner Tool (if you have CS3/CS4/CS5/CS6/CC), and reinstall.
    http://www.adobe.com/support/contact/cscleanertool.html

  • How to print date in dd/MM/yyyy format??

    Hi All,
    I want to print a date in a dd/MM/yyyy format. I am doing like this
    Date d = new Date(23-11-2006); but it is printing
    like Wed Dec 31 18:59:58 EST 1969 .
    Please help me .

    I am doing like this
    Date d = new Date(23-11-2006); but it is
    printing No you're not, because that won't compile. Show us exactly what you're doing and we might be able to help.
    You seem to suggest you want to print a date in a certain format, but then the (pseudo-) code you present seems to suggest you want to be able to parse a date from a given format into a Date object.
    Be clear and specific about exactly what you want, what you have tried, and why it didn't work and then people will be better placed to help! :-)

  • Re : how to print report output in DOT MATRIX printer

    Hai
           how to print report output in DOT MATRIX printer.
    Thanks
    mani

    Check this
    [http://help.sap.com/saphelp_nw04/helpdata/en/90/78f078030211d399b90000e83dd9fc/frameset.htm]
    also check the SAP Note 129581

  • Module Pool for displaying the Grid values in Matrix format

    Hi Experts,
    I have one requirement which as follows,
    In Module pool program i need to display the Grid Values in Matrix format i.e,
    Row = Color
    Column = Size
    Like what we can see in Sales order or Purchase Order if you click Grid Entries Button.
    Can you Please Help me out.
    Thanks n Advance.
    Logu

    Hi
    the sources ate the function groups WMMB and WMMA.
    In a new release you should find the function module MGW_UTILITIES_MATRIX_SHELL_RA
    the report RWRFMATCHARVAL is a good example
    Regards
    Björn

  • Module Pool to Display the Values in Matrix Format

    Hi Experts,
    I have one requirement which as follows,
    In Module pool program i need to display the  Values in Matrix format i.e,
    Row = Color
    Column = Size
    Can you Please Help me out.
    Thanks n Advance.
    Logu

    create your internal table dynamically (with number of columns corresponding to number of sizes)
    this is done easily with class CL_ALV_TABLE_CREATE method CREATE_DYNAMIC_TABLE
    then use the internal table for ALV output

  • HT4007 printing a light table on larger formate printers

    printing light table layout to large formate printers

    Hi mdlewis979. We are aware that you are being assisted through our email technical support group. Should you need immediate assistance, please contact us at 1-800-OK-CANON (1-800-652-2666).

  • Print out Forte Arrays

    Greetings All:
    I'd like to know if anyone has had any experience printing out
    Forte Arrays[screen tables] from the Forte Window it exists in.
    Example:
    A Forte window exists that contains Forte Arrays. I
    want an option to either select from the pulldown
    FILE menu or select a button which will automatically
    print out the contents of that Forte Array.
    Has anyone tried to resolve this kind of problem before?
    Regards,
    Antonio Mercado

    try this
    import java.io.*;
    import java.util.*;
    public class PrintE {
    public static void main (String [] args) {
    String line = null;
    String fname = null;
    Vector v=new Vector();
    try {
    System.out.println("Enter file for Entropy print out:");
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    fname = in.readLine();
    catch(IOException e){
    e.printStackTrace();
    try{
    String in= null;
    FileReader fr = new FileReader(fname);
    BufferedReader br = new BufferedReader(fr);
    while ((in = br.readLine()) !=null) {
    v.addElement(in);
    System.out.println(in); }
    catch(IOException e){
    e.printStackTrace();
    System.out.print("Enter line:");
    int index = Integer.parseInt(fname);
    System.out.println(.get(index -1)); //probs here
    assuming user enter say 4
    say
    index=4;
    then
    System.out.println(v.elementAt(index-1));
    hope this helps

  • Printer device group and a label format in SAP AII

    Hello @ all,
    I try to configure a SAP OER System with SAP AII. Now I should configure the label printing with the transaktion /AIN/ASGN_PRF_FORMAT. I must take a profile name, a printer device group and a label format. The problem is now, that I can't chose a printer device group and also I don't know the label format. Where can I adjust the printer device group and which label format must be in that field?
    Can anybody help me?
    Thank you.
    Peter

    Hi Peter,
    SAP AII sends the label format filename as part of the Command message xml to the printer during tag commissioning.
    I assume you have configured the label format filename for SAP_PRINT_PROFILE using transaction /AIN/ASGN_PRF_FORMAT - Assign Format to Printer and Profile
    Now you have to assign that profile to an ID type or GTIN, etc. using the menus under Profiles for Tag Commissioning and Label Printing.
    Once this configuration is done, the xml command message containing the element WriteTagData is sent to the printer RFC destination configured against the Device controller as an HTTP message.
    This command message will contain the label format and  field names - value pairs as per the SAP_PRINT_PROFILE.

  • Unable to print in 100 MM     36 MM format.

    Hi All,
    We are facing a print problem where we are unable to print in 100MM X 36MM Page Format(ZSTICKE which is created) This is of customized type, With LOCL output device the spool request is not getting generated. However we are able to see the print preview.
    while printing it gives a error "**Error while calling the smartform**"
    Now we tried to run a print with A4 (DINA4) size page format and it worked, we are able to see the print preview and also print.
    Could you please let us know what could be the issue as it works with A4 but not with customized page format(It however gives print preview even with customized page format
    Thanks in Advance.
    Vijay

    Hi Vijay,
    In SPAD Tcode u have to assign the page format to the printer and then only it will works. other wise it will show error.
    Regards,
    Sathis

  • Unable to print euro symbol in dot matrix printer

    i am unable to print euro symbol in dot matrix printer from abap list. whereas it is printed as '#'  symbol instead of euro.
    my sap product is ECC 6.0
    regards
    mohanraj

    Check this
    [http://help.sap.com/saphelp_nw04/helpdata/en/90/78f078030211d399b90000e83dd9fc/frameset.htm]
    also check the SAP Note 129581

Maybe you are looking for