C++ Program to Apply Above-Below-on Test to Find the Position of a Point with respect to a Line

Anvi Jain
Updated on 30-Jul-2019 22:30:25

627 Views

This is a C++ program to apply Above-Below-on Test to find the position of a point with respect to a Line. For any point t (xt, yt) on the plane, its position with respect to the line L connecting m and n is found by calculating the scalar s −Y = A xt + B yt + CIf Y< 0, t lies in the clockwise halfplane of L; if Y>0, t lies on the counter-clockwise halfplane; if Y= 0, t lies on L.AlgorithmBegin    Take the points as input.    For generating equation of the line, generate random numbers for ... Read More

Android Recyclerview GridLayoutManager column spacing

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

3K+ Views

This example demonstrates about Android Recyclerview GridLayoutManager column spacingStep 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 recyclerview.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.TargetApi; import android.os.Build; import android.os.Bundle; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; public class ... Read More

Can we order a MySQL result with mathematical operations?\\n

George John
Updated on 30-Jul-2019 22:30:25

308 Views

Yes, we can order with mathematical operations using ORDER BY clause. Let us first create a table:mysql> create table orderByMathCalculation    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Quantity int,    -> Price int    -> ); Query OK, 0 rows affected (0.57 sec)Following is the query to insert some records in the table using insert command:mysql> insert into orderByMathCalculation(Quantity, Price) values(10, 50); Query OK, 1 row affected (0.21 sec) mysql> insert into orderByMathCalculation(Quantity, Price) values(20, 40); Query OK, 1 row affected (0.14 sec) mysql> insert into orderByMathCalculation(Quantity, Price) values(2, 20); Query ... Read More

C++ Program to Implement Gauss Seidel Method

Smita Kapse
Updated on 30-Jul-2019 22:30:25

4K+ Views

Gauss Seidel method is used to solve linear system of equations in iterative method. This is a C++ Program to Implement Gauss Seidel Method.AlgorithmBegin    Take the dimensions of the matrix p and its elements as input.    Take the initials values of x and no of iteration q as input.    While q>0       Make a for loop i = 0 to p-1          initialize n[i] = (b[i] / a[i][i]).             Make a for loop i = 0 to p-1             If (j == ... Read More

Is there a built-in function for week of the month in MySQL?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

912 Views

There is no standard function to get week of month in MySQL. You need to use the following syntax −SELECT WEEK(yourDateColumnName, 5) - WEEK(DATE_SUB(yourDateColumnName, INTERVAL DAYOFMONTH(yourDateColumnName) - 1 DAY), 5) + 1 AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table FirstWeekOfMonth -> ( -> Id int NOT NULL AUTO_INCREMENT primary key, -> yourdate date -> ); Query OK, 0 rows affected (2.50 sec)Now you can insert some records in the table ... Read More

Add a value to Unit Tuple in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

210 Views

The addAtX() method is used to add value to the Tuple. The index can be set here with the X i.e. the place where the value gets added.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;Here, we have also used the Pair class, therefore import the following package also −import org.javatuples.Pair;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 ... Read More

Explain the architecture of JDBC?

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

4K+ Views

If you want to develop a Java application that communicates with a database, you should use JDBC API. A driver is the implementation of the said API; various vendors provide various drivers, you need to use a suitable driver with respect to the database you need to communicate with. The driver manager loads the driver and manages the driver.Following are the components of JDBC:JDBC DriverManager: The DriverManager class of the java.sql package manages different types of JDBC drivers. This class loads the driver classes. In addition to this whenever a new connection establishes it chooses and loads the suitable driver ... Read More

The hashCode() method of CopyOnWriteArrayList method in Java

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

243 Views

To get the hash code value of the list, you need to use the hashCode() method of the CopyOnWriteArrayList class.The syntax is as followspublic int hashCode()To work with CopyOnWriteArrayList class, you need to import the following packageimport java.util.concurrent.CopyOnWriteArrayList;The following is an example to implement CopyOnWriteArrayList class hashCode() method in JavaExample Live Demoimport java.util.concurrent.CopyOnWriteArrayList; public class Demo {    public static void main(String[] args) {       CopyOnWriteArrayList arrList = new CopyOnWriteArrayList();       arrList.add(30);       arrList.add(40);       arrList.add(60);       arrList.add(70);       arrList.add(90);       arrList.add(100);       arrList.add(120);   ... Read More

Best replacement of onItemClickListner in android recyclerview?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

177 Views

This example demonstrates about Best replacement of onItemClickListner in android recyclerviewStep 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 recyclerview.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.TargetApi; import android.os.Build; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.widget.TextView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { ... Read More

How to add column using alter in MySQL?\\n

George John
Updated on 30-Jul-2019 22:30:25

246 Views

Following is the syntax to add column using alter in MySQL:alter table yourTableName add column yourColumnName yourDataType default yourValue;Let us first create a table:mysql> create table alterTableDemo    -> (    -> Id int,    -> Name varchar(10)    -> ); Query OK, 0 rows affected (0.69 sec)Let us check the description of the table using DESC command. This displays Field, Type, Key, etc. of the table:mysql> desc alterTableDemo;This will produce the following output+-------+-------------+------+-----+---------+-------+ | Field | Type        | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | Id    | int(11)     | YES ... Read More

Advertisements