CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    2

    Exclamation Pls can someone tell me why my program cant run

    public class Chessboard{
    public static void main(String args[]){
    //read the numbers of square from command-line
    int n = Integer.parseInt(args[0]);

    // double x0,x1,y0,y1,;

    //Reset the scales on both axis
    StdDraw.setXscale(0.0 , 8.0);
    StdDraw.setYscale(8.0, 0.0);

    //Draw the (boundary of) chess board.
    // StdDraw.line....
    StdDraw.line(0.0,0.0,1.0,0.0);
    StdDraw.line(0.0,1.0,1.0,1.0);
    StdDraw.line(0.0,0.0,0.0,1.0);
    StdDraw.line(1.0,0.0,1.0,1.0);

    //Draw sqaures on the chess board
    StdDraw.square(0.0, 0.5 ,0.0 );
    StdDraw.square(0.5, 0.5 ,0.5 );

    StdDraw.filledSquare(1.5, 0.5, 0.5);
    StdDraw.text(0.5 , 0.5 , "W");
    StdDraw.setPenColor(StdDraw.WHITE);
    StdDraw.text(1.5 , 0.5, "B");

    for(int i = 0; i<n ; i++) {
    for(int j =0; j<n ; j++) {

    // Draw squares based on whether the sum of
    // their row and colomn is even or odd.


    if(( i % == 1) && (j % == 1)){

    //draw odd sqaure
    }
    else {
    //draw even sqaure
    }
    }
    }


    //send output to screen and file
    StdDraw.show();
    StdDraw.save("chessboard.png");

    }
    }

  2. #2
    Join Date
    Oct 2012
    Posts
    2

    Re: Pls can someone tell me why my program cant run

    It gives me this on my IDE
    2 errors found:
    File: C:\Users\ODUWOLE\Documents\Concordia Files\COURSES\COMP 218\Java\Chessboard.java [line: 35]
    Error: illegal start of expression
    File: C:\Users\ODUWOLE\Documents\Concordia Files\COURSES\COMP 218\Java\Chessboard.java [line: 35]
    Error: illegal start of expression

  3. #3
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Pls can someone tell me why my program cant run

    Please use code tags when posting code

    The compiler is complaining about the code on line 35.
    I suspect it's the following line as it's not a legal use of the % (remainder) operator
    Code:
    if(( i % == 1) && (j % == 1))
    I suggest you read a tutorial on how to use the remainder operator
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured