# Java Program to Swap Two Numbers

Here you will get java program to swap numbers using temporary variable. It can be done in following way. temp = a a = b b = temp Also Read: Java Program to Swap Two Numbers Without Using Third Variable

Output Enter first number: 5 Enter second number: 8 Before swap: a = 5 b = 8 After swap: a = 8 b = 5

# Java Program for Addition of Two Numbers

Here you will get java program for addition of two numbers. It is the very basic java program that is useful for beginners.

Output Enter first number: 8 Enter second number: 4 Sum = 12

# Java Program to Calculate Compound Interest

Here you will get java program to calculate compound interest. We can calculate compound interest by following formula. Compound Interest = Principle * (1 + Rate / 100) time Also Read: Java Program to Calculate Simple Interest

Output Enter principle: 1000 Enter rate: 4 Enter time: 10 Compound Interest = 1480.2442849183444

# Java Program to Calculate Simple Interest

Here you will get java program to calculate simple interest. We can calculate simple interest in java by using following formula. Simple Interest = (Principle x Rate x Time) / 100 Also Read: Java Program to Calculate Compound Interest

Output Enter principle: 1000 Enter rate: 3 Enter time: 2 Simple Interest = 60.0

# 4 Ways to Calculate Power of Number in Java

Here I have shared the 4 different ways to calculate power of number in Java. Using Loop Using Recursion Using Math.pow() Using BigInteger.pow() 4 Ways to Calculate Power of Number in Java 1. Using Loop We can calculate the power of number by repeatedly multiplying the number by itself in a loop. This method works only for positive integer power.

Output Enter a number and its power: 3 3 27   2. Using Recursion Recursion can also be

# Program for Armstrong Number in Java

Here you will get program for armstrong number in java. A number which is equal to the sum of its digits raised to the power n is called armstrong number. Here n is the total digits in the given number. Example: 9 is an armstrong number as n = 1 and 91 = 9. 153 is an armstrong number as n = 3 and 13 + 53 + 33 = 1 + 125 + 27 = 153. Program for Armstrong Number in Java