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

Java Programs Part 1

The document contains five simple Java programs with objectives and successful execution results. The programs include Hello World, addition of two numbers, finding the largest of three numbers, calculating factorial, and checking for palindrome numbers. Each program is accompanied by its code and demonstrates basic Java programming concepts.

Uploaded by

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

Java Programs Part 1

The document contains five simple Java programs with objectives and successful execution results. The programs include Hello World, addition of two numbers, finding the largest of three numbers, calculating factorial, and checking for palindrome numbers. Each program is accompanied by its code and demonstrates basic Java programming concepts.

Uploaded by

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

Simple Java Programs

Program 1: Hello World


Objective: Write and execute the following Java program.
public class HelloWorld {
public static void main(String[] args) {
[Link]("Hello World");
}
}
Result: The program was executed successfully.
Simple Java Programs
Program 2: Addition of Two Numbers
Objective: Write and execute the following Java program.
import [Link];
class Add {
public static void main(String args[]){
Scanner s=new Scanner([Link]);
int a=[Link]();
int b=[Link]();
[Link]("Sum = "+(a+b));
}
}
Result: The program was executed successfully.
Simple Java Programs
Program 3: Largest of Three Numbers
Objective: Write and execute the following Java program.
import [Link];
class Largest{
public static void main(String args[]){
Scanner s=new Scanner([Link]);
int a=[Link](),b=[Link](),c=[Link]();
if(a>b && a>c) [Link](a);
else if(b>c) [Link](b);
else [Link](c);
}
}
Result: The program was executed successfully.
Simple Java Programs
Program 4: Factorial
Objective: Write and execute the following Java program.
import [Link];
class Factorial{
public static void main(String args[]){
Scanner s=new Scanner([Link]);
int n=[Link](),f=1;
for(int i=1;i<=n;i++) f*=i;
[Link](f);
}
}
Result: The program was executed successfully.
Simple Java Programs
Program 5: Palindrome Number
Objective: Write and execute the following Java program.
import [Link];
class Palindrome{
public static void main(String args[]){
Scanner s=new Scanner([Link]);
int n=[Link](),t=n,r=0;
while(n>0){ r=r*10+n%10; n/=10; }
[Link](t==r?"Palindrome":"Not Palindrome");
}
}
Result: The program was executed successfully.

You might also like