Found 33676 Articles for Programming

Java Program for Arithmetic Operations Between BigDecimal and Primitive Data Types

Mr. Satyabrata
Updated on 23-Jan-2025 23:07:25

301 Views

In this article, we will explore how to perform arithmetic operations between BigDecimal and Primitive data types by using Java. For instance, Addition: The sum of a BigDecimal object with a value of 10.50 and an int primitive with a value of 5 is a BigDecimal object with a value of 15.50. 10.50 + 5 = 15.50 SyntaxThe syntax doubleValue() method returns the value of a BigDecimal object as a double primitive type. double doubleNum1 = num1.doubleValue(); Where “num1” is a BigDecimal object. What is BigDecimal in Java? BigDecimal is a class in Java's java.math package that ... Read More

Python - K difference index Pairing in List

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:23:22

188 Views

The K is the special number that set the sum of the difference values starting with 0th index. For example, if k = 3 it means the 0th index added with K and finds the exact pairs. In Python, we have some built-in functions such as str(), len(), and append() will be used to solve the K difference index pairing in list. Let’s take an example of list. The given list, [“A”, “B”, “C”, “D”, “E”, “F”] Then the K value set to 1 The final output pair the index as [“AC”, “BD”, “CE”, ... Read More

Find Difference Between Sum of All Rows and All Columns in Java

Mr. Satyabrata
Updated on 17-Aug-2023 17:21:36

170 Views

In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to add sum of all individual rows and columns. Then we need to perform the difference between these added rows and columns and display the result. Let's start! For instance Suppose the original matrix is: {4, 2, 1}, {3, 5, 6}, {8, 9, 7} After performing ... Read More

Check if the Sum of Digits of a Number N Divides It

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:19:17

311 Views

The N number is the special number of integer type that calculates the individual digit of sum. So, this sum will be divisible by its own number. Let’s take an example of this. The given integer number, N = 36 The sum of each digit, 3 + 6 = 9 Therefore, 36 is successfully divisible by 9 and it verifies for N divides it. Algorithm The following steps are- Step 1: We will start the program by mentioning the header file iostream. Step 2: Common Matches:- Then used the function definition digit_sum() that accepts the parameter a variable n ... Read More

How to Sort a Pandas DataFrame by Date?

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:16:25

3K+ Views

Python’s Pandas DataFrame defines the two-dimensional structure that consists of rows and columns. The main feature of pandas is an easier way of handing the given data. In Python, we have some in-built functions such as to_datetime(), sorted(), lambda, and, sort_value() will be Sort a Pandas DataFrame by Date. Syntax The following syntax is used in the examples- to_datetime() The to_datetime() is an in-built function in Python that convert string dates into date-time objects. sorted() The built-in function sorted() of Python states that the list can be sort as specified iterable objects. lambda This lambda function in ... Read More

Python - Filter Tuples with All Even Elements

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:14:59

299 Views

The problem statement allows us to determine the position of the desired string in the list, which can be useful for various purposes, such as accessing or manipulating elements at that specific index. In Python, we have some built-in functions like reduce(), str(), filter(), lambda, and, all() that will be used to Find Index Containing String in List. Syntax The following syntax is used in the examples- reduce() This function is defined under the functools module str() This is a built-in method in Python that can convert the specified value into a string. filter() The ... Read More

Get Interior & Exterior Angle of Regular Polygon When Numbers of Sides of Polygon is Given in Java

Mr. Satyabrata
Updated on 17-Aug-2023 17:17:31

135 Views

A polygon is a 2-dimensional closed shape that has at least 3 sides. Depending on the number of sides, relationships of the sides and angles, and other characteristics, polygons can be classified under different names like triangles, squares, and quadrilaterals. An interior angle of a polygon is an angle formed inside the two adjacent sides of a polygon. Exterior angle is defined as the angle formed between a side of triangle and an adjacent side extending outward. In this article, we will find interior and exterior angle of regular polygon when numbers of sides of polygon is ... Read More

Check if a Word is Present in a Sentence

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:05:20

1K+ Views

A sentence is a group of words that are present in a string. In this problem statement, we need to set a specific word and check whether the word is present in a given string or not. In C++, we have some pre-defined functions such as find(), npos(), and istringstream() will be used to Check if a word is present in a sentence. Using Standard library Function The program uses a standard library function that allows the programmer to use pre-existing functions of the C compiler such as find() and npos() to perform certain tasks. Syntax The following syntax is ... Read More

Check if a number with even number of digits is palindrome or not

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:02:54

377 Views

The palindrome refers to same number when the digits are reversed. In this program, we need to set the condition and operation based on an even number of digits to identify whether the given input satisfied for palindrome or not. In C++, we have STL(Standard template library) functions such as to_string(), length(), rbegin(), rend(), and, push_back() will be used to Check if a number with an even number of digits is palindrome or not. For example- 2662, 42124, 44, 888, etc are satisfied for even digit palindrome numbers. Using for loop and if-else statement The program uses for loop to ... Read More

How to Know the Separator for a Particular File System in Java

Mr. Satyabrata
Updated on 17-Aug-2023 17:13:07

1K+ Views

In Java, the file separator is a character that separates the components of a file path. The file separator varies depending on the operating system on which the Java program is running. On Windows systems, the file separator is backslash (\). On Unix-based systems (such as Linux and macOS), the file separator is forward slash (/). Let's start! For instance Suppose that we running the code on windows system After performing the operation to get the separator, the result will be: Separator for this file system is: \ Algorithm Step-1: Import the necessary libraries. ... Read More

Advertisements