Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
simple java question 10POINTS?
import java.util.*;
public class checkerBoard
{
public static void main(String[] arg)
{
int i,j;
for(i=0;i>8;i++){
for(j=0;j>8;j++){
if(j%==0)
System.out.println("o");
else
System.out.println("x");
}
}
}
}
i get an error that says illegal start of expression on the line that says if(j%==0)
SOLVE THIS AND ILL PICK U AS BEST ANSWER FIRST COME FIRST SERVE! GET 10 FREE POINTS!
3 Answers
- ?Lv 410 years agoFavorite Answer
% the modulus operator works with two variables or values
what i mean is
4%2==0;
As the modulus retrieves the remainder,
It must have.
for your program
if(j%i==0)
Your problem is solved!
- Michael GLv 410 years ago
You have tried to use the modulus operator without saying something on the other side of the %. I THINK you want 2 for this i.e. if(j%2==0), which tests to see if j is even.
EDIT: Also, use the bracket things ({ and }) when you are using if statements,
if(j%==0){
System.out.println("o");
} else {
System.out.println("x");
}
EDIT 2 : You say for(i=0;i>8;i++), which means that the program will never run as i is never greater than eight, the same for the other for loop. Change > for <.
- green meklarLv 710 years ago
The % operator only works between two integer values or two floating point values. You have nothing on the right-hand side of the % operator. Java doesn't know what you mean by this, so it refuses to compile it. For that matter, I don't know what you mean by it either.
Also, can you explain why you expect either of those for loops to run even once? The initial value in each case, 0, is already not greater than 8, so the conditions will never be satisfied.