JAVA APPLICATION PROGRAMMING
This document contains simple Java programs prepared in a normal classroom / lab record
style. Programs are written in a straightforward manner, similar to how students usually
write in Word files.
Program 1: Display Two Integer Values
public class TwoIntegers {
public static void main(String[] args) {
int x = 12;
int y = 8;
[Link](x);
[Link](y);
}
}
Output:
12
8
Program 2: Area of Rectangle
public class RectangleArea {
public static void main(String[] args) {
int l = 10;
int b = 5;
int area = l * b;
[Link](area);
}
}
Output:
50
Program 3: Simple Interest
public class SimpleInterest {
public static void main(String[] args) {
int p = 1000;
int t = 2;
int r = 5;
int si = (p * t * r) / 100;
[Link](si);
}
}
Output:
100
Program 4: Swap Two Numbers
public class SwapNumbers {
public static void main(String[] args) {
int a = 5, b = 10, temp;
temp = a;
a = b;
b = temp;
[Link](a);
[Link](b);
}
}
Output:
10
5
Program 5: Check Even Number
public class EvenCheck {
public static void main(String[] args) {
int n = 6;
if(n % 2 == 0)
[Link]("Even");
}
}
Output:
Even