Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could not find or load Error in java

 
Sky Mendoza
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to compile it but I cant let it run. I dont even know if the code I did is right or what. But here it is:
public class OddOrEven{
public static void main(String []args){
int x = 1;
if (x > 1000){
if (x < 1){
System.out.println("Accepted");
}else if (x < 1000){
System.out.println("Error");
}else if (x > 1){
System.out.println("Error");
if (x % 2 == 0){
System.out.println("Even");
}else{
System.out.println("Odd");
}
}
}
}
}




I should make a code that only accepts 0-1000 else print error then it should show if it is even or odd. Thanks in advance and sorry for my english. Haha
 
Vijay Vishwa
Ranch Hand
Posts: 38
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Combi,

Please do use the code tag by clicking on the code button. It will make the code readable and give response.

 
Vijay Vishwa
Ranch Hand
Posts: 38
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding you question.

The first if condition is wrong itself.
If you want ot accept values between 0 and 1000(both inclusive) then it should be
 
Sky Mendoza
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh thanks. Im not really good at programming because i'm only 1st year college.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic