Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-09-2008, 04:53 AM
debug debug is offline
Newbie
 
Join Date: Aug 2007
Posts: 14
Rep Power: 0
debug is on a distinguished road
Default need some help

Quote:
import java.util.*;
public class puzzle{
final static int MAX_ROW = 8;
final static int MAX_COL = 4;
static int numRow;
static int grid[][] = new int[MAX_ROW][MAX_COL];
public static void main(String[] args){
System.out.println(" Enter the number of row:");
Scanner myScanner = new Scanner(System.in);
numRow = myScanner.nextInt();
for(int i = 0; i < numRow; i++)
{
for (int j = 0; j < MAX_COL; j++)
{
System.out.print(grid[i][j]);
}
System.out.println();
}
}
}
m writing a code to display the tic-tae-toe board but when i run the code the display show only 0 . Can someone help me which part of my code went wrong?? thkx in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-12-2008, 04:38 PM
gszauer's Avatar   
gszauer gszauer is offline
Programmer
 
Join Date: Nov 2007
Location: Florida
Age: 18
Posts: 113
Rep Power: 3
gszauer is on a distinguished road
Default Re: need some help

You have nothing to turnicate one row, and start the second.
Do this
import java.util.*;

Code:
public class puzzle{
  final static int MAX_ROW = 8;
  final static int MAX_COL = 4;
  static int numRow;
  static int grid[][] = new int[MAX_ROW][MAX_COL];
  public static void main(String[] args){
    System.out.println(" Enter the number of row:");
    Scanner myScanner = new Scanner(System.in);
    numRow = myScanner.nextInt();
    for(int i = 0; i < numRow; i++)    {
      for (int j = 0; j < MAX_COL; j++)    {
        System.out.print(grid[i][j]);
      }
      System.out.print("\n");
    }
    System.out.println();
  }
}
__________________
Quote:
Originally Posted by ~Aristotle
It is the mark of an educated mind to entertain a tought without accepting it
If my post was helpful, please help me build some rep
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 04:00 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads