• 30 March

    java random number between 1 and 10

    We have already seen random number generator in java.In this post, we will address specific query on how to generate random number between 1 to 10. Using random.nextInt() to generate random number between 1 and 10 We can simply use Random class’s nextInt() method to achieve this. As the documentation says, this method call returns "a […]

  • 01 August

    Count Factorial Trailing Zeroes in java

    In this tutorial, we will see how to count trailing zeros in factorial of a number in java. Problem Count number of zeros in factorial of number in java. For example: Factorial of 6 is 720, so a number of trailing zeros is 1. Factorial of 14 is 87 178 291 200, so a number […]

  • 20 January

    Java program to print Fibonacci Series

    In this tutorial, we will print fibonacci series. According to wikipedia: In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones:[1][2] 0,1,1,2,3,5,8,13,21,34,55,89,144.. Here is simple program to print […]

  • 19 January

    Java program for sum of digits of number

    In this post, we will see how to find sum of digits of number in java. You can find unit’s place digit by number%10, add it to the total and divide the number by 10 to remove the unit’s place. import java.util.Scanner; public class DigitAdditionCalc { public static void main(String args[]) { int number, remdr=0, […]

  • 19 January

    Java program to calculate average marks

    In this post, we will see simple java program to find average and percentage marks. We have taken average and percentage of five subject marks below. import java.util.Scanner; public class MarksCalculator { public static void main(String args[]) { int markArray[] = new int[5]; int i; float sum=0; float average, percentage; Scanner scan = new Scanner(System.in); […]

  • 18 January

    Even odd program in java

    In this post,we will see how to check if number is even odd. It is one of the basic programs of Java programming language. import java.util.Scanner; public class EvenOddFinder { public static void main(String args[]) { int num; Scanner scanner = new Scanner(System.in); System.out.print("Enter a Number : "); num = scanner.nextInt(); if(num%2 == 0) { […]

  • 18 January

    Java Program to add two numbers

    In this post, we will see how to add two numbers in java. This is the most basic program of java programming language. import java.util.Scanner; public class Calculator { public static void main(String args[]) { int num1, num2, sum; // Taking input from user Scanner scanner = new Scanner(System.in); System.out.print("Enter two numbers : "); num1 […]

  • 24 December

    Reverse number in java

    In this post, we will see how to reverse a number in java. Here is simple program to reverse a number. package org.arpit.java2blog; import java.util.Scanner; public class ReverseNumberMain { public static void main(String[] args) { int number, reversedNumber=0, remainder; Scanner scan = new Scanner(System.in); System.out.print("Enter a Number : "); number = scan.nextInt(); while(number != 0) […]

  • 10 November

    Java Format number as currency

    In this post, we are going to see how to format currency in java. We can format number into Currency by using NumberFormat class.We need to call NumberFormat.getInstance()  to get NumberFormat object by passing specified locale. For example: Let’s say you want a Format object for UK Locale or US Locale. You can simply use below […]

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.