Found 2616 Articles for Java

How To Check if a Given Point Lies Inside a Rectangle in Java?

Mr. Satyabrata
Updated on 17-Nov-2022 11:11:23

3K+ Views

A rectangle is a closed two-dimensional shape which has 4 sides and 4 corners. The opposite sides are of the same length and parallel to each other. All the 4 interior angles are equal, angles measure 90 degrees each. It is a four-sided polygon. We will see 2 approaches in this program. If bottom left corner and top right corner point values are given If four points of the rectangle are given If bottom left corner and top right corner point vales are given Then the given point x−coordinate should lie inside the x−coordinate of the rectangle and ... Read More

How to Calculate Area of Enneagon in Java?

Mr. Satyabrata
Updated on 17-Nov-2022 10:58:33

112 Views

An enneagon refers to a polygon with 9 sides with 9 internal angles. Where all the sides of the polygon are equal it is called a regular enneagon which has an internal angle of 140 degrees, and the sum of all internal angles are 1260 degrees. An enneagon is also referred to as Nonagon. Area of enneagon can be calculated by using When Length of Side (s) is given Area = 6.1818 * (s * s) When circumradius (r) is given Area = 2.8925 * (r * r) When apothem (a) is given Area = 3.2757 * (a ... Read More

How To Find Volume of the Octahedron in Java?

Mr. Satyabrata
Updated on 28-Oct-2022 08:15:14

126 Views

An octahedron is a three-dimensional shape which has eight plane faces. Simply, it is a polyhedron with eight faces, twelve edges and 6 vertices. It is derived from a Greek word i.e. ‘Oktaedron’ which means Eight Faced. Formula to find volume of octahedron − $$\mathrm{Volume\: =\: \sqrt{2}/3\: × \:a^3}$$ Where, ‘a’ refers to the side of the octahedron. In this article we will see how we can find the volume of the octahedron in Java. To show you some instances Instance-1 Suppose the side length is 3 Then according to the volume formula of octahedron − Volume = 12.72 ... Read More

How To Find Volume of Dodecahedron in Java?

Mr. Satyabrata
Updated on 28-Oct-2022 08:02:13

144 Views

A dodecahedron is a three-dimensional shape which has twelve flat faces. It is derived from two Greek words i.e. ‘dodeka’ which means 12 and ‘hedra’ which means face. Simply, it is a polyhedron with twelve sides or faces. It is also called dodecahedron. Formula to find volume of dodecahedron − $$\mathrm{Volume \:=\: (15\: +\: 7\sqrt{5})*a^3/4}$$ Where, ‘a’ refers to the edge of the dodecahedron. In this article we will see how we can find the volume of the dodecahedron in Java. To show you some instances Instance-1 Suppose the edge length is 4 Then according to the volume formula ... Read More

How To Find the Midpoint of a Line in Java?

Mr. Satyabrata
Updated on 28-Oct-2022 07:50:57

2K+ Views

Let's say (x1, y1) is the starting point of line and (x2, y2) is the end point of line. To get the midpoint of line we have to use the midpoint formula of line. Midpoint = ((x1+x2)/2 , (y1+y2)/2) In this article we will see how to find the midpoint of line when two points of the line are given by using Java Programming language. To show you some instances Instance-1 Let say the two points are (2, 3) and (3, 5) By using the midpoint formula of line, a = (x1+x2)/2 = (2+3)/2 = 2.5 b = (y1+y2)/2 ... Read More

How To Find Minimum Height of the Triangle with Given Base and Area in Java?

Mr. Satyabrata
Updated on 28-Oct-2022 07:39:20

511 Views

We have the area of triangle ‘a’ and base ‘b’. As per problem statement we have to find the minimum height ‘h’ by using Java programming language. As we know area of triangle, when base and height are given − $$\mathrm{area \:=\: \frac{1}{2}\: * \:base\: *\: height}$$ By using above formula, we can get height from it − height = (2 * area) / base Then by using the inbuilt ceil() method we can get the minimum height. To show you some instances Instance-1 Suppose, given area = 12 and base = 6 Then by using the ... Read More

How To Check Whether a Number is a Unique Number or Not in Java?

Mr. Satyabrata
Updated on 28-Oct-2022 07:22:24

7K+ Views

Unique number can be defined as a number which does not have a single repeated digit in it. Simply it means all the digits of that number are unique digits, no duplicate digits are there in that number. In this article we will see how to check whether a number is a unique number or not by using Java programming language. To show you some instances Instance-1 Input number is 145 Let’s check it by using the logic of unique number − The digits are 1, 4, 5, all are unique digits. Hence, 145 is a unique number. Instance-2 ... Read More

How to Check Whether a Number is a Triangular Number or Not in Java?

Mr. Satyabrata
Updated on 28-Oct-2022 07:13:29

3K+ Views

Triangular number of a natural ‘n’ can be defined as the sum of all natural numbers from 1 to n. It is called as triangular as we can represent it in the form of an equilateral triangular grid by using the total number of points where the row number equals the point number. Means in 1st row 1 point, in 2nd row 2 points, in 3rd row 3 points and so on. In simple terms we can say a number is a triangular number if it is the sum of all consecutive numbers starting from 1. Mathematically n*(n+1)/2 In ... Read More

How To Check Whether a Number is a Sunny Number or Not in Java?

Mr. Satyabrata
Updated on 28-Oct-2022 07:01:10

5K+ Views

A number is said to be a Sunny number, if the square root of the next value of input number is a perfect square of any number. For more clarification, if we add one to any number we get the next value. After that we have to find out the square root of it. If we get any integer value then we can say that it is a perfect square of any number. If we confirm that the next number has a perfect square number then the input number is a sunny number otherwise it is not a sunny number. ... Read More

How To Check Whether a Number Is a Niven Number or Not in Java?

Mr. Satyabrata
Updated on 27-Oct-2022 13:17:17

9K+ Views

Niven number can be defined as a number which is divisible by the sum of its digits. It is also called as Harshad number. In this article we will see how to check Niven numbers by using the Java programming language. To show you some instances Instance-1 Input number is 3 Let’s check it by using the logic of Niven number − Sum of the digits of the number = 3. So, 3 is divisible by 3. Hence, 3 is a Niven number. Instance-2 Input number is 18 Let’s check it by using the logic of Niven number − ... Read More

Advertisements