Samual Sam has Published 2496 Articles

Java program to sort integers in unsorted array

Samual Sam

Samual Sam

Updated on 28-Jun-2024 18:19:18

2K+ Views

Sorting refers to arranging data in a particular format. Sorting algorithm specifies the way to arrange data in a particular order (ascending or descending). Problem Statement For a given array write Java program to sort integers in unsorted array. Consider the following example - Input The unsorted integer ... Read More

Java Program to Toss a Coin

Samual Sam

Samual Sam

Updated on 28-Jun-2024 11:20:56

3K+ Views

Tossing a coin is flipping a coin into the air and letting it fall back down. When you toss a coin, it's like a game where you can choose heads or tails, and the side that lands facing up is the result. This method is used when we want to ... Read More

Reading and writing binary file in C/C++

Samual Sam

Samual Sam

Updated on 26-Jun-2024 23:28:09

59K+ Views

Writing To write a binary file in C++ use write() method. It is used to write a given number of bytes on the given stream, starting at the position of the "put" pointer. The file is extended if the put pointer is currently at the end of the file. If ... Read More

Difference between an SAP ERP system and DBMS

Samual Sam

Samual Sam

Updated on 25-Jun-2024 16:17:28

2K+ Views

DBMS or Database Management system is basically the tool/interface required to manage the database.  For example, SQL server or a tool like MYSQL workbench is a DBMS. A DBMS is mainly used by or designed for technical people.ERP (Enterprise Resource Planning System) is a complete system with one database and ... Read More

Java Program to convert String to Boolean

Samual Sam

Samual Sam

Updated on 21-Jun-2024 13:09:42

15K+ Views

To convert String to Boolean, use the parseBoolean() method in Java. The parseBoolean() parses the string argument as a boolean. The boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string "true".Firstly, declare a string.String str = "false";Now, use ... Read More

Java program to calculate the product of two numbers

Samual Sam

Samual Sam

Updated on 21-Jun-2024 12:47:09

8K+ Views

The * operator in Java is used to multiply two numbers. Read required numbers from the user using Scanner class and multiply these two integers using the * operator.Exampleimport java.util.Scanner; public class MultiplicationOfTwoNumbers {    public static void main(String args[]){       Scanner sc = new Scanner(System.in);     ... Read More

Java Program to locate a character in a string

Samual Sam

Samual Sam

Updated on 21-Jun-2024 11:27:10

13K+ Views

To locate a character in a string, use the indexOf() method.Let’s say the following is our string.String str = "testdemo";Find a character ‘d’ in a string and get the index.int index = str.indexOf( 'd');Example Live Demopublic class Demo {    public static void main(String []args) {       String str ... Read More

Java Program to swap the case of a String

Samual Sam

Samual Sam

Updated on 18-Jun-2024 18:01:46

12K+ Views

To swap the case of a string, use.toLowerCase() for title case string. toLowerCase() for uppercase stringtoUpperCase() for lowercase stringLoop through what we discussed above for all the characters in the sting.for (int i = 0; i > len; i++) {    c = str.charAt(i);    // title case converted to ... Read More

Java program to find the area of a rectangle

Samual Sam

Samual Sam

Updated on 18-Jun-2024 16:59:45

9K+ Views

Area of a rectangle is the product of its length and breadth. Therefore, to calculate the area of a rectangleGet the length of the rectangle form the user.Get the breadth of the rectangle form the user.Calculate their product.Print the product.ExampleBelow is an example to find the area of a rectangle ... Read More

Java Program to fill an array of characters from user input

Samual Sam

Samual Sam

Updated on 18-Jun-2024 16:45:18

14K+ Views

For user input, use the Scanner class with System.in. After getting the input, convert it to character array −char[] a = s.next().toCharArray();Now, display it until the length of the character array i.e. number of elements input by the user −for (int i = 0; i < a.length; i++) {   ... Read More

1 2 3 4 5 ... 250 Next
Advertisements