The document contains 3 Java programs: 1) A simple "Hello World" program that prints "hello world", 2) A program that checks if a number is a perfect number by calculating the sum of its factors, 3) A program that checks if a number is a neon number by squaring it and summing its digits then comparing to the original number.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
24 views5 pages
Java Program
The document contains 3 Java programs: 1) A simple "Hello World" program that prints "hello world", 2) A program that checks if a number is a perfect number by calculating the sum of its factors, 3) A program that checks if a number is a neon number by squaring it and summing its digits then comparing to the original number.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5
Java Programs
Contents-
Simple hello world program
Perfect number Neon number Class hello { Public static void main() { System.out.println(“hello world”); } } import java.util.*; class perfect { public static void perfect() { Scanner in=new Scanner(System.in); System.out.println("Enter a number"); int n=in.nextInt(); int i=1; int s=0; while(i<n) { if(n%i==0) s=s+i; i++; } if(s==n) System.out.println("perfect number"); else System.out.println("not a perfect number"); } import java.util.*; class neon { public static void neon() { Scanner in=new Scanner(System.in); System.out.println("Enter a number"); int n=in.nextInt(); int sq=n*n; int s=0; int i=sq; while(i>0) { int r=i%10; s=s+r; i=i/10; } if(s==n) System.out.println("the number is neon number"); else System.out.println("the number is not a neon number");