tag:blogger.com,1999:blog-2964959029992147971.post4132828945641710506..comments2024-02-12T20:14:00.868+05:30Comments on InstanceOfJava: Program to print prime numbers in javasaideshhttp://www.blogger.com/profile/03671387577197113199noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-2964959029992147971.post-39321772548750714182017-10-03T20:56:45.374+05:302017-10-03T20:56:45.374+05:30Good work sir, Thanks for the proper explanation a...Good work sir, Thanks for the proper explanation about <a href="https://goo.gl/qFs5EH" rel="nofollow"> JAVA </a> . I found one of the good resource related <a href="https://goo.gl/qFs5EH" rel="nofollow"> JAVA </a> and <a href="https://goo.gl/vXihRN" rel="nofollow">OOPS concepts</a>. It is providing in-depth knowledge on <a href="https://goo.gl/qFs5EH" rel="nofollow"> JAVA </a> and <a href="https://goo.gl/vXihRN" rel="nofollow">OOPS</a>. which I am sharing a link with you where you can get more clear on <a href="https://goo.gl/qFs5EH" rel="nofollow"> JAVA </a> and <a href="https://goo.gl/vXihRN" rel="nofollow">OOPS</a>. To know more Just have a look at this link <br /><br /><a href="https://goo.gl/qFs5EH" rel="nofollow">Java Tutorial</a><br /><a href="https://goo.gl/T9Jjvk" rel="nofollow">Class and object</a><br /><a href="https://goo.gl/TkpQrB" rel="nofollow">Inheritance</a><br /><a href="https://goo.gl/KQC4fN" rel="nofollow">Polymorphism</a><br /><a href="https://goo.gl/rNXq8n" rel="nofollow">Abstraction</a><br /><a href="https://goo.gl/iD4x3a" rel="nofollow">Encapsulation</a><br />,,Anonymoushttps://www.blogger.com/profile/10079686091396065014noreply@blogger.comtag:blogger.com,1999:blog-2964959029992147971.post-10719155043662811112016-10-07T19:37:27.640+05:302016-10-07T19:37:27.640+05:30nice postnice postAnonymoushttps://www.blogger.com/profile/10393064892485610658noreply@blogger.comtag:blogger.com,1999:blog-2964959029992147971.post-9163535893851872302016-08-12T19:34:03.683+05:302016-08-12T19:34:03.683+05:30Yes, the above program is not correct. To print pr...Yes, the above program is not correct. To print prime numbers, the logic mentioned here is not correct. Please see correct logic to print all prime numbers till the input upperbase number<br /><br />import java.util.Scanner;<br /><br /><br />public class PrimeNumbers {<br /><br /> /**<br /> * @param args<br /> */<br /> public static void main(String[] args) {<br /> // TODO Auto-generated method stub<br /><br /> PrimeNumbers object = new PrimeNumbers();<br /> object.printPrimeNumbers();<br /> <br /> }<br /><br /> <br /> public void printPrimeNumbers(){<br /> <br /> int upperBase;<br /> int num;<br /> System.out.println("Enter the upper base number:");<br /> Scanner input = new Scanner(System.in);<br /> upperBase = input.nextInt();<br /> input.close();<br /> <br /> System.out.println("\nPrime numbers between 0 and "+upperBase+" are:\t");<br /> <br /> for(int i=2; i<=upperBase;i++){<br /> <br /> int count=0;<br /> <br /> for(num=i;num>1;num--){<br /> <br /> if(i%num==0){<br /> count++;<br /> <br /> }<br /> }<br /> <br /> if(count==1){<br /> System.out.println(i);<br /> }<br /> <br /> }<br /> <br /> }<br />}<br />Thomas Cheriyanhttps://www.blogger.com/profile/06032016205199723599noreply@blogger.comtag:blogger.com,1999:blog-2964959029992147971.post-47005151165425933862016-02-15T22:29:24.925+05:302016-02-15T22:29:24.925+05:30your program is to print even numbers, not primeyour program is to print even numbers, not primeAnonymoushttps://www.blogger.com/profile/09441966271506180390noreply@blogger.comtag:blogger.com,1999:blog-2964959029992147971.post-49183819411721982982016-02-10T12:04:38.894+05:302016-02-10T12:04:38.894+05:30public class Print_prime {
public void findPrim...public class Print_prime {<br /> <br /> public void findPrime (int start_number, int last_number){<br /> System.out.println("prime number between "+start_number+" and "+last_number<br /> +" are");<br /> for (int i = start_number; i < last_number+1; i++) {<br /> if(i%2 == 0){<br /> <br /> System.out.println(i);<br /> }<br /> }<br /> }<br /> <br /> public static void main(String[] args) {<br />Print_prime pp = new Print_prime();<br />pp.findPrime(10, 101);<br /> }<br /><br />}Anonymoushttps://www.blogger.com/profile/18107816437186009217noreply@blogger.comtag:blogger.com,1999:blog-2964959029992147971.post-30135040253325662712015-11-09T14:38:51.404+05:302015-11-09T14:38:51.404+05:30how this count functions in this program?how this count functions in this program?Anonymoushttps://www.blogger.com/profile/09772978722565794429noreply@blogger.com