0% found this document useful (0 votes)
37 views5 pages

Java Programs: Hello, Perfect, Neon

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.

Uploaded by

fin o
Copyright
© All Rights Reserved
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% found this document useful (0 votes)
37 views5 pages

Java Programs: Hello, Perfect, Neon

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.

Uploaded by

fin o
Copyright
© All Rights Reserved
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

Java Programs

Contents-

Simple hello world program


Perfect number
Neon number
Class hello
{
Public static void main()
{
[Link](“hello world”);
}
}
import [Link].*;
class perfect
{
public static void perfect()
{
Scanner in=new Scanner([Link]);
[Link]("Enter a number");
int n=[Link]();
int i=1;
int s=0;
while(i<n)
{
if(n%i==0)
s=s+i;
i++;
}
if(s==n)
[Link]("perfect number");
else
[Link]("not a perfect number");
}
import [Link].*;
class neon
{
public static void neon()
{
Scanner in=new Scanner([Link]);
[Link]("Enter a number");
int n=[Link]();
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)
[Link]("the number is neon number");
else
[Link]("the number is not a neon number");

You might also like