Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
class Divisible
{
	public static void main(String args[])
	{
		int number[]=new int[200];
		int i,sum=0;
		
		for(i=0;i<number.length;i++)>
		{
			number[i]=i;
		}
		
		for(i=0;i<number.length;i++)>
		{
			if((number[i]>100) && (number[i]<200) && (number[i]/7))
			{
				sum=sum+number[i];
			}
		}
		
		System.out.println("Sum =" +sum);
	}
}


What I have tried:

i am new to java language so i basically don't know anything about this type of error and what needs to be done......so would be a great help to know the answer and thanks in advance...
Posted
Updated 4-Jul-16 2:53am
v2

(number[i]/7)?
It is not a boolean expression but a numeric value...
 
Share this answer
 
Comments
OriginalGriff 4-Jul-16 8:40am    
Snap! :laugh:
And then he asks me for a code example that I already gave... :doh:
Kornfeld Eliyahu Peter 4-Jul-16 8:45am    
You should write it out with larger font, and probably repeat the whole code snippet form the original post to put it in context... The problem is that you are too lazy :-) (Look at my - much more detailed - answer!)
OriginalGriff 4-Jul-16 8:53am    
So, you're suggesting:
<span style="font-family: verdana;font-size:200px;color:red">RTFM</span>
:laugh:
Kornfeld Eliyahu Peter 4-Jul-16 9:12am    
You should add it to your pre-recorded answers... :-)
OriginalGriff 4-Jul-16 9:24am    
I could dump most the rest if I did that! :laugh:
&& is the Logical AND operator: it needs boolean values on both sides.
(number[i]/7) is not a boolean value - you probably mean something like:
Java
if((number[i]>100) && (number[i]<200) && (number[i]/7 > 0))
 
Share this answer
 
Comments
Member 12617696 4-Jul-16 8:33am    
so what modifications needs to be done??? show it via code..??
OriginalGriff 4-Jul-16 8:39am    
Um ... did you read what I wrote?
Kornfeld Eliyahu Peter 4-Jul-16 8:44am    
Come on! You have high expectations today!
The problem is that (number[i]/7) is not a boolean/logical value.
you need something like (number[i]/7 <> 0).
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900