Day: April 18, 2021

Java Example – Java Program to Swap Two Numbers

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 …

Learn Java by Example: Java Program to Compute Quotient and Remainder

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 = …

Learn Java by Example: Java Program to Find ASCII Value of a character

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 = …

Learn Java by Example: Java Program to Multiply two Floating Point Numbers

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 = …