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

Java Programs Part 5

The document contains five simple Java programs with objectives and successful execution results. Programs include swapping numbers, calculating simple interest, printing 'Hello World', adding two numbers, and finding the largest of three numbers. Each program is accompanied by its source code and confirms successful execution.

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 5

The document contains five simple Java programs with objectives and successful execution results. Programs include swapping numbers, calculating simple interest, printing 'Hello World', adding two numbers, and finding the largest of three numbers. Each program is accompanied by its source code and confirms successful execution.

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: Swap Numbers


Objective: Write and execute the following Java program.
class Swap{
public static void main(String args[]){
int a=10,b=20,t;
t=a; a=b; b=t;
[Link](a+" "+b);
}
}
Result: The program was executed successfully.
Simple Java Programs
Program 2: Simple Interest
Objective: Write and execute the following Java program.
import [Link];
class Interest{
public static void main(String args[]){
Scanner s=new Scanner([Link]);
float p=[Link](),t=[Link](),r=[Link]();
[Link]((p*t*r)/100);
}
}
Result: The program was executed successfully.
Simple Java Programs
Program 3: 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 4: 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 5: 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.

You might also like