Average of n Numbers in Java

In this post, we’ll see various ways of calculating average of n numbers in Java.1) Average of 3 input numbers2) Average of n numbers input by user3) Average of the numbers in an array Average of 3 input numbers: We are calling nextLine to read the newline character entered after the number. If we do … Read more

Addition of Two Numbers in Java

We will solve this basic problem of the addition of two numbers in three ways, first by using a Scanner, second by using BufferedReader, and at last by using command-line arguments. Addition of two numbers using Scanner Java provides Scanner class in java.util package. This class is very popular to read values from the user … Read more

Finding Maximum of Three Numbers in Java

In this post, we will see 2 variations of finding maximum of 3 numbers in Java: (A) Max value of 3, (B) Max variable of 3 numbers. Max Value of 3 Max Variable of 3

How to Convert an Integer to Octal in Java

Java wrapper class Integer provides an utility function toOctalString(int) which returns an integer in octal form. However, in this post, we will also see an example on how we can convert integer to octal form mathematically without using Java API classes. If you divide a number with 8, what you get in the reminder is … Read more

How to Reverse an Integer in Java

In this example, we will see how to reverse an integer in Java using mathematical equations, StringBuffer and StringBuilder classes. Reverse an Integer in Java using Mathematical Equations To reverse an integer mathematically, first thing what we should do is to take out the last digit as a separate integer. That is possible by dividing … Read more