Home
Tutorials
Core Java
Introduction To Java
Java Evolution
Overview of Java
Constants, Variables and Data Types
Java Operators
Branching Statements
Looping Statements
Classes, Objects and Methods
Inheritance
Array, String and Vectors
Java Interfaces
Java Packages
Applet Programming
Graphics Programming
Advanced Java
Java AWT
Java Event Handling
Java File Handling
Java MultiThreading
Java Swing-I
Java Swing-II
Exception Handling
Socket Programming
Java Database
Java RMI
Java Servlets
Java Beans
Programms
Projects
Downloads
Contact
Java Programming
!doctype>
Break Statement in Java While Loop to Check that Given Number is Prime or Not
//Break Statement import java.io.*; class BreakStatement { public static void main(String args[]) throws Exception { String a; int n,i = 2; System.out.print("\n\tEnter the Number :\t"); BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); a = obj.readLine(); n = Integer.parseInt(a); while(i<=n) { if(n%i==0) { break; } i++; } if(n == i) { System.out.print("\n\t"+n+" is Prime Number\n"); } else { System.out.print("\n\t"+n+" is not Prime Number\n"); } } }
Output of "BreakStatement.java"
Download Complete Program
-
Read more »
No comments:
Post a Comment
No comments:
Post a Comment