Java Program to Convert Octal Number to Decimal and vice-versa In this program, you’ll learn to convert octal number to a decimal number and vice-versa using functions in Java. Example 1: Program to Convert Decimal to Octal public class DecimalOctal { public static void main(String[] args) { int decimal = 78; int octal = convertDecimalToOctal(decimal);…
Read more
Java Program to Convert Binary Number to Decimal and vice-versa In this program, you’ll learn to convert binary number to a decimal number and vice-versa using functions in Java. Example 1: Program to convert binary number to decimal public class BinaryDecimal { public static void main(String[] args) { long num = 110110111; int decimal =…
Read more
Java Program to Find Factorial of a Number Using Recursion In this program, you’ll learn to find and display the factorial of a number using a recursive function in The factorial of a positive number n is given by: factorial of n (n!) = 1 * 2 * 3 * 4 * … * n…
Read more
Java Program to Find the Sum of Natural Numbers using Recursion In this program, you’ll learn to find the sum of natural number using recursion in Java. This is done with the help of a recursive function. The positive numbers 1, 2, 3… are known as natural numbers. The program below takes a positive integer…
Read more
Java Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers In this program, you’ll learn to check whether a given number can be expressed as a sum of two prime numbers or not. This is done with the help of loops and break statements in Java. To accomplish this…
Read more
Java Program to Make a Simple Calculator Using switch…case In this program, you’ll learn to make a simple calculator using switch..case in Java. This calculator would be able to add, subtract, multiply and divide two numbers. Example: Simple Calculator using switch Statement import java.util.Scanner; public class Calculator { public static void main(String[] args) { Scanner…
Read more
Java Program to Display Factors of a Number In this program, you’ll learn to display all factors of a given number using for loop in Java. Example: Factors of a Positive Integer public class Factors { public static void main(String[] args) { int number = 60; System.out.print(“Factors of ” + number + ” are: “);…
Read more