0% found this document useful (0 votes)
3 views2 pages

Java Programme 1

Uploaded by

vijayanagani.sri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Programme 1

Uploaded by

vijayanagani.sri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java Programming [ Lab Programs ]

Aim:
Use eclipse or Netbean platform and acquaint with the various menus, create a test
project, add a test class and run it see how you can use auto suggestions, auto fill. Try
code formatter and code refactoring like renaming variables, methods and classes. Try
debug step by step with a small program of about 10 to 15 lines which contains at least
one if else condition and a for loop.

Source Code:

Sample_Program.java

/* Sample java program to check given number is prime or not */


//Importing packages
import [Link];
import [Link];
// Creating Class
class Sample_Program {
// main method
public static void main(String args[]) {
int i,count=0,n;
// creating scanner object
Scanner sc=new Scanner([Link]);
// get input number from user
[Link]("Enter Any Number : ");
n=[Link]();
// logic to check prime or not
for(i=1;i<=n;i++) {
if(n%i==0) {
count++;
}
}
if(count==2)
[Link](n+" is prime");
else
[Link](n+" is not prime");

}
}

Output:

You might also like