Found 9326 Articles for Object Oriented Programming

Java Program to Display Factors of a Number

AmitDiwan
Updated on 22-Feb-2022 08:15:19

6K+ Views

In this article, we will understand how to display factors of a number. Factor are number that divides another number or expression evenly.Factors are the numbers we multiply to get another number. For example, if we multiply 3 and 5, we get 15. We say, 3 and 5 are factors of 15. Alternatively, factors of a number are those numbers which divide that number without leaving any remainder. For example, 1, 2, 3, 4, 6, and 12 are factors of 12 as all of them divide it evenly.The largest and smallest factors of a number. The largest factor of any ... Read More

Java Program to Display Prime Numbers Between Intervals Using Function

AmitDiwan
Updated on 22-Feb-2022 07:59:51

382 Views

In this article, we will understand how to display prime numbers between intervals using function. Prime numbers are special numbers who have only two factors 1 and itself and cannot be divided by any other number.A number is a prime number if its only factors are 1 and itself. 11 is a prime number. Its factors are 1 and 11 itself. Some examples of prime numbers are 2, 3, 5, 7, 11, 13 and so on. 2 is the only even prime number. All other prime numbers are odd numbers.Below is a demonstration of the same −InputSuppose our input is ... Read More

Java Program to Display Prime Numbers Between Two Intervals

AmitDiwan
Updated on 22-Feb-2022 07:50:11

2K+ Views

In this article, we will understand how to display prime numbers between two intervals. Prime numbers are special numbers who have only two factors 1 and itself and cannot be divided by any other number.A number is a prime number if its only factors are 1 and itself. 11 is a prime number. Its factors are 1 and 11 itself. Some examples of prime numbers are 2, 3, 5, 7, 11, 13 and so on. 2 is the only even prime number. All other prime numbers are odd numbers.Below is a demonstration of the same −InputSuppose our input is −Starting ... Read More

Java Program to Find the Area of a Parallelogram

AmitDiwan
Updated on 22-Feb-2022 07:40:07

355 Views

In this article, we will understand how to find the area of a parallelogramA parallelogram has two pairs of parallel equal opposite sides. It has a base and a height which is the perpendicular distance between the base and its opposite parallel side.The area of a parallelogram is calculated using the formula −base * height i.e. b x hBelow is a demonstration of the same −InputSuppose our input is −Base : 6 Height : 8OutputThe desired output would be −Area parallelogram is : 48 AlgorithmStep 1 - START Step 2 - Declare three integer values values namely Step 3 - ... Read More

Java Program to Perform nCr (rcombinations)

AmitDiwan
Updated on 22-Feb-2022 07:35:09

374 Views

In this article, we will understand how to compute the combination using n and r values. The nCr is calculated using the formula −(factorial of n) / (factorial of (n-r))Below is a demonstration of the same −InputSuppose our input is −Value of n : 6 Value of r : 4OutputThe desired output would be −The nCr value is : 15AlgorithmStep 1 - START Step 2 - Declare two integer values namely n and r. Step 3 - Read the required values from the user/ define the values Step 4 - Define two functions, one function to calculate the factorial of n and ... Read More

Java Program to Find the Surface area and Volume of Cuboid

AmitDiwan
Updated on 22-Feb-2022 07:28:57

398 Views

In this article, we will understand how to compute the surface area and volume the cuboid. Cuboid is a three-dimensional object with six faces of rectangle shape which means it has sides of different length and breadth. The difference between a cube and cuboid is that a cube has equal length, height and breadth whereas in cuboids these three are not sameThe surface area of cuboid is calculated using the formula −2*( length *width + width* height + height*length)The area of the cuboid is calculated using the formula −length*width*heightBelow is a demonstration of the same −InputSuppose our input is −Length= ... Read More

Java Program to Find the Perimeter of a Circle

AmitDiwan
Updated on 21-Feb-2022 13:18:08

817 Views

In this article, we will understand how to find the perimeter of a circle. The circumference is the perimeter of a circle. It's the distance around a circle.Circumference is given by the formula C = 2𝜋\pi r where, \pi𝜋 = 3.14 and r is the radius of the circle −Below is a demonstration of the same −InputSuppose our input is −Radius of the circle : 5OutputThe desired output would be −Perimeter of Circle is: 31.428571428571427 AlgorithmStep 1 - START Step 2 - Declare 2 double values namely my_radius and my_perimeter Step 3 - Read the required values from the user/ ... Read More

Java Program to Find the Area of a Trapezium

AmitDiwan
Updated on 21-Feb-2022 13:14:53

534 Views

In this article, we will understand how to find the area of a trapezium. Trapezium is a type of quadrilateral that has at least one pair of side parallel to each other. The parallel sides of a trapezium are called bases and the non-parallel sides of a trapezium are called legs. It is also called a trapezoid.The area of a trapezium is calculated using the formula −(height/2 * (side_1 + side_2). i.e. Area = ½ x (sum of the lengths of the parallel sides) x perpendicular distance between parallel sidesBelow is a demonstration of the same. Area of a trapezium ... Read More

Java Program to Reverse a Number

AmitDiwan
Updated on 21-Feb-2022 13:04:36

453 Views

In this article, we will understand how to print an integer in Java. The reverse of a number is computed using a loop and arithmetic operator % and /.Below is a demonstration of the same −InputSuppose our input is −The number : 123456OutputThe desired output would be −The result is 654321 AlgorithmStep 1 - START Step 2 - Declare three integer values namely my_input, reverse_input and remainder. Step 3 - Read the required values from the user/ define the values Step 4 – Run a while loop Step 5- Use modulus of 10 and get remainder for ‘my_remainder’ . Step ... Read More

Java Program to Print the Multiplication Table in Triangular Form

AmitDiwan
Updated on 21-Feb-2022 12:52:45

257 Views

In this article, we will understand how to print multiplication table in triangular form. Printing multiplication table in triangular form is achieved using a loop.Below is a demonstration of the same −InputSuppose our input is −Input : 7OutputThe desired output would be −The result is : 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 6 12 18 24 30 36 7 14 21 28 35 42 49AlgorithmStep 1 - START Step 2 - Declare 3 integer values namely my_input, I and j Step 3 - Read the required values from the user/ define ... Read More

Advertisements