Java Program to Check Whether a Number is Even or Odd In this program, you’ll learn to check if a number entered by an user is even or odd. This will be done using if…else statement and ternary operator in Java. Example 1: Check whether a number is even or odd using if…else statement …
Day: April 18, 2021
Java Program to Swap Two Numbers In this program, you’ll learn two techniques to swap two numbers in Java. The first one uses a temporary variable for swapping, while the second one doesn’t use any temporary variables. Example 1: Swap two numbers using temporary variable public class SwapNumbers{ public static void main(String[] args){ float …
Java Program to Compute Quotient and Remainder In this program, you’ll learn to compute quotient and remainder from the given dividend and divisor in Java. Example: Compute Quotient and Remainder public class QuotientRemainder{ public static void main(String[] args){ int dividend = 25, divisor = 4; int quotient = dividend / divisor; int remainder = …
Java Program to Find ASCII Value of a character In this program, you’ll learn to find and display the ASCII value of a character in Java. This is done using type-casting and normal variable assignment operations. Example: Find ASCII value of a character public class AsciiValue{ public static void main(String[] args){ char ch = …
Java Program to Multiply two Floating Point Numbers In this program, you’ll learn to multiply two floating point numbers in Java, store the result and display it on the screen. Example: Multiply Two Floating-Point Numbers public class MultiplyTwoNumbers{ public static void main(String[] args){ float first = 1.5f; float second = 2.0f; float product = …