Found 33676 Articles for Programming

Java Program to Print Summation of Numbers

Shriansh Kumar
Updated on 30-Sep-2024 15:46:44

792 Views

Suppose you are given a set of numbers, your task is to write a Java program to print their summation. To find summation, you need to add all the given numbers with the help of addition operator. In Java, a set of numbers can be represented by an array. Let's understand the problem with an example − Example Scenario: Input: number_set = 34, 11, 78, 40, 66, 48; Output: summation = 277 Sum of all the numbers is 277 as 34 + 11 + 78 + 40 + 66 + 48 = 277. Using Iteration The most ... Read More

Java Program to Open the given URL in System Default Browser in Windows

Saba Hilal
Updated on 23-Mar-2023 12:37:46

6K+ Views

There are different ways of viewing web pages in a browser using URL. Here, the methods of doing the same are specified using the Java code. The given URL is first entered by using the Java program. Then the related Webpage is opened in the default browser. This article uses three different approaches for opening the webpage as specified by the URL in the browser through the Java code. Multiple Approaches For these programs, the displaying of the given URL is done using two different approaches. By Using desktop.browse(uri) for the object belonging to Desktop class. By Using javafx ... Read More

Java program to print Swastika by taking input from user

Saba Hilal
Updated on 27-Aug-2024 18:47:37

1K+ Views

Swastika is a religious symbol of Hinduism, Buddhism, and Jainism. In this article, we will learn to print Swastika by taking user input. Here, are three different approaches for making this design using Java. In all the approaches, the size of the Swastika is decided by the user. The user provides the input for the table or frame size. The Swastika is often used as an example to learn rows, columns, and tabular layout concepts using different languages including Java. Making Swastika using Java. Here, three different approaches are used to make this design using Java − ... Read More

Java Program to open the Command Prompt and Insert commands

Saba Hilal
Updated on 24-Jun-2024 15:53:26

8K+ Views

This article uses various approaches for selecting the commands inserted in the opened command window through the Java code. The command window is opened by using ‘cmd’. Here, the methods of doing the same are specified using Java code. The Command window is first opened using the Java program. It is opened as a child process. If the java program is run in an existing cmd window, another one is opened as a new process. Further, different types of commands are inserted and executed in that opened command window via the java code. These programs may not work in ... Read More

Java program to read a large text file line by line

Saba Hilal
Updated on 08-Nov-2024 22:30:45

701 Views

This article includes the way to read text files line by line in Java. Here, the three different methods are explained with examples. Storing a file in text format is important especially when data from one structured /unstructured form is transferred to another form. Therefore, basic file transfer systems integrate the txt file reading and writing process as their application components. Therefore, how to use text file reading and writing methods is also important for making the parsers. Multiple Approaches The given problem statement is solved in three different approaches − By using the BufferedReader ... Read More

Java Program to Print the Elements of an Array

Shriansh Kumar
Updated on 30-Jul-2024 17:00:39

960 Views

Array is the common way to store similar types of items together in Java. The stored items or values are referred as elements of the array. In this article, we are going to learn how to create an array and print its elements. Printing elements of an array in Java Use the following approaches to print elements of an array − By using for loop By using while loop By using Arrays.toString() method For Loop to Print array elements For loop is used when we know how many times a task needs to be repeated. In this case, ... Read More

Java Program to Print the Months in Different Formats

Saba Hilal
Updated on 11-Sep-2024 11:02:56

824 Views

In this article, we are going to use various approaches for formatting the months using different libraries of Java programming language. There are several ways to display months. Sometimes the months are written as numbers, sometimes the months are written in long form or they are written in short forms. Using java.time.Month In this approach, the months are printed by specifying the month number that starts from the number 1. For instance -> Month.of(1) will give JANUARY. Example In this Java program, we are printing all 12 months name. import java.time.Month; public class ShowMonth { ... Read More

Commands to Get Min, Max, Median, and Mean of a Dataset

Satish Kumar
Updated on 23-Mar-2023 16:33:43

2K+ Views

When working with datasets, it's important to understand characteristics of data. One of most fundamental aspects of a dataset is its central tendency - point around which data tends to cluster. This can be quantified in a number of ways, including minimum, maximum, median, and mean. In this article, we'll explore these different measures of central tendency and show you how to calculate them using a variety of programming languages. What is Minimum of a Dataset? The minimum of a dataset is smallest value in set. This value is useful for understanding lower bounds of data and can help identify ... Read More

Modelling the Secant Method in Python

Dr Pankaj Dumka
Updated on 15-Mar-2023 17:05:48

3K+ Views

Secant method is one of the powerful methods to know the x-intercept (zeros) of a polynomial or any transcendental function. In this method, first we select (basically guess) the interval in which we expect the root ($\mathrm{𝑥_{1}}$, $\mathrm{𝑥_{2}}$). Then we draw a secant line to join the points on the function (A, B) corresponding to the guessed values as shown in the figure below. The secant line intersects the x-axis at the point $\mathrm{𝑥_{3}}$, as $\mathrm{𝑥_{3}}$ and $\mathrm{𝑥_{2}}$ are not close (i.e., their absolute difference is finite) we find the point corresponding to 𝑥3 on the curve i.e., C. ... Read More

Modelling the Regula Falsi Method in Python

Dr Pankaj Dumka
Updated on 15-Mar-2023 16:46:15

2K+ Views

In this tutorial, I will show you how to find the roots of an equation with the help of Regula Falsi which is also called as the "False Position Method". Let us consider the figure shown below. First we have searched for two 𝑥 values $\mathrm{x_{1}}$ and $\mathrm{x_{2}}$ at which the value of function ($\mathrm{y_{1}} $and $\mathrm{y_{2}}$) are different, means the points should be such that the products of these two should be negative (i.e. they should lie on the opposite sides of the X-axis). As these are not the exact point i.e. the points at which root exist, ... Read More

Advertisements