October 26th, 2012 10:38 AM
#1
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");
}
}
October 26th, 2012 11:05 AM
#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
October 29th, 2012 11:56 AM
#3
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
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
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks