**ALL CODES ARE 100 % ERROR FREE**
- **CODES ARE ALSO CHECKED THOROUGHLY**
- In this code snippet we will learn how to get Greatest Common Divisor in Java, Implementation of Euclidean Algorithm to get Highest Common Divisor.
- The Euclidean algorithm is used to find the Greatest Common Divisor and Highest Common Divisor of two numbers. Greatest Common Divisor is calculated by divide both numbers with their common divisorpublic class Gcd {
- // greatest common divisor
- public static int gcd(int First_number, int Second_number) {
- int i = First_number % Second_number;
- while (i != 0) {
- First_number = Second_number;
- Second_number = i;
- i = First_number % Second_number;
- }
- return Second_number;
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("First Number :");
- int num1 = sc.nextInt();
- System.out.print("Second Number :");
- int num2 = sc.nextInt();
- System.out.println("Greatest Common Divisors: " + gcd(num1, num2));
- }
- }
- In this code snippet we will learn how to get Greatest Common Factor in Java, Implementation of Euclidean Algorithm to get Highest Common Factor.
- The Euclidean algorithm is used to find the Greatest Common Factor and Highest Common Factor of two numbers. Highest Common Factor is calculated by divide both numbers with their common factor.
- EMI Calculator in Java - This program will read Loan Amount, Interest Rate and Time in Years and calculate monthly EMI.
- Enter day no and year to get the actual date
- Java Math Methods
- Basic Math methods
- Logarithmic Math Methods
**CODES ARE ALSO CHECKED THOROUGHLY**
HERE ARE THE CODING OF JAVA BASIC PROGRAMS WHICH IS SUITABLE FOR ALL WITH EXPLANATIONS
***ALL CODES ARE CONTRIBUTED BY PARARDHA DHAR***
<1.Java program to print 'Hello world' (First program in Java)
How to print different type of values in Java?
How to read and print an integer value in Java?
Java program to find sum and average of two integer numbers
Java program to find sqare,cube and square root of a given number
Java program to swap two numbers with and without using third variable
Java program to check number is positive, negative or zero.
Java - Calculate Compound Interest using Java Program.
Java - Calculate LCM (Least Common Multiple) using Java Program.
Java program to find largest number among three numbers.
Java program to check whether year is Leap year or not.
Java - Greatest Common Divisor or Euclidean Algorithm Program or Highest Common Divisor.
In this code snippet we will learn how to get Greatest Common Divisor in Java, Implementation of Euclidean Algorithm to get Highest Common Divisor.
The Euclidean algorithm is used to find the Greatest Common Divisor and Highest Common Divisor of two numbers. Greatest Common Divisor is calculated by divide both numbers with their common divisorpublic class Gcd {
// greatest common divisor
public static int gcd(int First_number, int Second_number) {
int i = First_number % Second_number;
while (i != 0) {
First_number = Second_number;
Second_number = i;
i = First_number % Second_number;
}
return Second_number;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("First Number :");
int num1 = sc.nextInt();
System.out.print("Second Number :");
int num2 = sc.nextInt();
System.out.println("Greatest Common Divisors: " + gcd(num1, num2));
}
}
Java - Greatest Common Factor or Euclidean Algorithm Program or Highest Common Factor.
In this code snippet we will learn how to get Greatest Common Factor in Java, Implementation of Euclidean Algorithm to get Highest Common Factor.
The Euclidean algorithm is used to find the Greatest Common Factor and Highest Common Factor of two numbers. Highest Common Factor is calculated by divide both numbers with their common factor.
Java program to find Largest of Three Numbers
Largest of Three Numbers in Java - This program will read three integer numbers from the user and find the largest number among them, here we will find the largest number using if else conditions, ternary operator and function/method.
EMI Calculator in Java - Java program to calculate EMI.
EMI Calculator in Java - This program will read Loan Amount, Interest Rate and Time in Years and calculate monthly EMI.
Java program to Calculate Perimeter of a Circle.
Find Perimeter of Circle in Java - This program will read radius from the user and calculate the Perimeter of the circle.
CALENDAR PROGRAM
Enter day no and year to get the actual date
Java Math classJava Math class provides several methods to work on math calculations like min(), max(), avg(), sin(), cos(), tan(), round(), ceil(), floor(), abs() etc. Unlike some of the StrictMath class numeric methods, all implementations of the equivalent function of Math class can't define to return the bit-for-bit same results. This relaxation permits implementation with better-performance where strict reproducibility is not required. If the size is int or long and the results overflow the range of value, the methods addExact(), subtractExact(), multiplyExact(), FOR LIVE DEMO OF THIS FOLLOWING PROGRAM GO HERE http://tpcg.io/kLhmHLLv Java Math MethodsThe java.lang.Math class contains various methods for performing basic numeric operations such as the logarithm, cube root, and trigonometric functions etc. The various java math methods are as follows: Basic Math methods
Logarithmic Math Methods
|