Here is a C++ program to use above below primitive to test whether two lines intersect. It can be used to test whether a line intersects a line segment. It does if and only if one endpoint of the segment is to the left of the line and the other is to the right.AlgorithmBegin For generating equation of the first line, generate random numbers for coefficient of x and y by using rand at every time of compilation. For generating equation of the second line, generate random numbers for coefficient of x and y by using rand at ... Read More
This example demonstrates about Detect home button press in androidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken a text view.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { TextView text; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... Read More
To suppress MySQL stored procedure output, you can use variable. Let us first create a table.mysql> create table person_information -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.50 sec)Following is the query to insert some records in the table using insert command:mysql> insert into person_information values(100, 'John'); Query OK, 1 row affected (0.17 sec) mysql> insert into person_information values(101, 'Chris'); Query OK, 1 row affected (0.22 sec) mysql> insert into person_information values(102, 'Robert'); Query OK, 1 row affected (0.16 sec)Following is the query to display records from ... Read More
This is a C++ Program to optimize Wire Length in Electrical Circuit.AlgorithmBegin Function optimizeLength() : 1) Declare a array dist[N]. 2) sptSet[i] will be true if component i is included in shortest path tree or shortest distance from src to i is finalized. 3) Initialize all distances as INFINITE and stpSet[] as false 4) Distance of source component from itself will be always 0. 5) Run a for loop cnt = 0 to N-2, Find shortest path for all components. A) Pick the minimum distance component from the set of ... Read More
A duplicate buffer of a buffer can be created using the method duplicate() in the class java.nio.ShortBuffer. This duplicate buffer is identical to the original buffer. The method duplicate() returns the duplicate buffer that was created.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { ShortBuffer buffer1 = ShortBuffer.allocate(5); buffer1.put((short)12); buffer1.put((short)91); buffer1.put((short)25); buffer1.put((short)18); ... Read More
The Model ALS-NIFC-07 which on approximating successfully ADC is clearly described in this topic. It consists of a programmable timer interface which connects to the kit of ALS-SDA-85M by using a flat cable of 26 crores. The connector C1 gets connected to the interface by the Input Output connector P3 in the kit for the ALS, which is implemented on a flat cable. The power supply of +12V, -12V, +5V, and GND gets connected to the interface. The circuit description is shown below –C1 is connected to connector P3 (or P4) on ALS kit, for ADC interface purposeC2 is connected ... Read More
To search a value in Unit class in JavaTuples, use the contains() method.Let us first see what we need to work with JavaTuples. To work with the Unit class in JavaTuples, you need to import the following package −import org.javatuples.Unit;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Unit Class in Java Tuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Unit; public class Demo { public static void main(String[] args) { ... Read More
This example demonstrate about How to open youtube app from webview in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken web view to show youtube app.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ProgressDialog; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.EditText; public class MainActivity extends AppCompatActivity { ... Read More
To create LabelValue tuple from another collection, use the fromCollection() method or the fromArray() method. Here, we will be creating LabelValue from List, therefore use the fromCollection() method.Let us first see what we need to work with JavaTuples. To work with LabelValue class in JavaTuples, you need to import the following package.import org.javatuples.LabelValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples.Steps: How ... Read More
The SQL Count() function returns the number of rows in a table. Using this you can get the number of rows in a table.select count(*) from TABLE_NAME;Suppose we have established a connection with MySQL and created a table in the database named mydatabase using Statement object as://Creating the Statement object Statement stmt = con.createStatement(); //Query to create a table String query = "CREATE TABLE Cricketers_Data( " + "First_Name VARCHAR(255), " + "Last_Name VARCHAR(255), " + "Date_Of_Birth Date, " + "Place_Of_Birth VARCHAR(255), " + "Country VARCHAR(255))"; //Executing the query stmt.execute(query); System.out.println("Table created......");In to this table we ... Read More