954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

connecting two then statements

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++;	
		}
	}
}
Progr4mmer
Junior Poster
113 posts since Nov 2009
Reputation Points: 11
Solved Threads: 10
 

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.

Akill10
Posting Pro
575 posts since Sep 2010
Reputation Points: 115
Solved Threads: 80
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: