im trying to make so one if has two outcomes
ex:
if(prime % chk == 0) prime++ (and) chk++;

i want to know how to put (and) into code so it does both if prime % chk == 0

this is what i have for my prime finder

class Number {
	static public void main(String[] args) {
		int prime = 3;
		int test = 2;
		int fin = 0;
		int chk = prime - 1;
		while (fin < 100) {
			if(prime % chk == 0) prime++ + chk++;
			else chk--;
			if(chk == 0) System.out.println(prime);
			if(chk == 0) prime++;	
		}
	}
}

Instead of using inline code, create an if block using the {} braces.

if(prime % chk == 0)
{
prime++;
chk++;
}

This is the extreme basics. Java,C#,C++ and many other languages(if not all) use code blocks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.