Dear reader, today we will read in Java program to to find power of a number. Java Program to calculate power of a number using while loop public class JavaExample { public static void main(String[] args) { int number = 5, p = 2; long result = 1; int i=p; while (i != 0) { ..
Category : Java Interview Q&A
Dear reader, today we will read in Java program to find Quotient and Remainder, when one number is divided by another number. To find the quotient we divide num1 by the num2 / div operator. Since both the variable number 1 and number 2 are integers, the result of 15/2 will be an integer even ..
Dear reader, today we will read in Java program to to calculate simple interest. Simple interest formula Simple interest = (P × R × T) / 100 P is the principal amount. R is the rate per year. T is the time in years. For example: Suppose a person deposits 2000 INR in a bank ..
Dear reader, today we will read in Java program to calculate compound interest. Compound Interest Formula Compound interest is calculated using the following formula: P (1 + R/n) (nt) – P Here P is principal amount. R is the annual interest rate. t is the time the money is invested or borrowed for. n is ..
Dear reader, today we will read in Java program whether the character is a vowel or a consonant. The letters A, E, I, O and U (smallcase and uppercase) are known as vowels and the rest of the letters are known as consonants. Here we will write a Java program that checks whether the input ..
Dear reader, today we will create a java program to check whether the input year is a leap year. Before we look at the program, determine how to see if a year is mathematically a leap year: To determine whether a year is a leap year, follow these steps: 1. If the year is equally ..
Here we will see two Java programs, the first program takes two integer numbers (entered by the user) and displays the product of these numbers. The second program takes any two numbers (may be integers or floating points) and displays the result. Program to read two integer and print product of them This program asks ..
Hello readers In this tutorial, we will read a Java program to add two binary numbers. A binary number system has only two symbols 0 and 1, so a binary number has only 0 and 1. Before we write a program in addition to this, let us see how we add on paper, it is ..
In this program, you will learn to check whether the number entered by the user is even or odd. This will be done using the … if statement and the ternary operator in Java. Example 1: Check Even or Odd number in Java Program import java.util.Scanner; class CheckEvenOdd { public static void main(String args[]) { ..
Hi Friends We see two programs here to add two numbers, in the first program we specify the value of both numbers in the program itself. The second program takes both numbers (entered by the user) and prints the sum. 1. Sum of two numbers in Java Program public class AddTwoNumbers { public static void ..