Area of Triangle Formed by Axes and a Given Straight Line

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

147 Views

Here we will see how to get the area of a triangle formed by the x and y axis and another straight line. The diagram will be look like below. The equation of the straight line is −𝑎𝑥+𝑏𝑦+𝑐=0The line is cutting the x-axis at the point B, and cutting the y-axis at the point A. The intercept form will be like below −So the x-intercept is −𝑐∕𝑎 and y-intercept is −𝑐∕𝑏 . So the area of the triangle isExample Live Demo#include #include using namespace std; double areaTriangle(double a, double b, double c){    return fabs((c*c) / (2*a*b)); } main() {   ... Read More

Packaging and Publishing Python Code

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

272 Views

Python provides a very simple way of creating or publishing packages.Package management in Python is available through different tools−Pip- It remains one of the preferred choices because it virtually eliminates any manual installs and updates of software packages to operating systems. It manages full lists of packages and their corresponding version numbers, which fosters precise duplication of entire package groups in a distinct, separate environment.Python Package Index (PPI) is a public package repository of user-submitted packages that can be installed using pip .i.e. pip install package_name.Below is a step-by-step procedure on how to upload the package.Step 1: Have a package ... Read More

Set Default Button for JFrame in Java

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

1K+ Views

To set default button for JFrame, use the setDefaultButton() method −JFrame frame = new JFrame(); frame.getRootPane().setDefaultButton(button);The following is an example to set default button for JFrame −Exampleimport java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo {    public static void main(String args[]) {       JButton button = new JButton("Demo Button!");       JFrame frame = new JFrame();       frame.setSize(500, 300);       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       frame.getRootPane().setDefaultButton(button);       button.setMnemonic(KeyEvent.VK_A);       button.addActionListener(new ActionListener() {          public void actionPerformed(ActionEvent ae) {         ... Read More

Insert EditText for Text Input on Android Notification

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

383 Views

This example demonstrate about How can I insert an EditText (for inserting text) on an Android notificationStep 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.     Step 3 − Add the following code to res/layout/custom_notification_layout.xml.             Step 4 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.RemoteViews ... Read More

Delete Partial Data in MongoDB

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

162 Views

You can use map() for this. Let us first create a collection with documents −> db.deleteDemo.insertOne({"Name":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd550492cba06f46efe9f06") } > db.deleteDemo.insertOne({"Name":"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd5504d2cba06f46efe9f07") } > db.deleteDemo.insertOne({"Name":"Sam"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd550512cba06f46efe9f08") } > db.deleteDemo.insertOne({"Name":"David"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd5505d2cba06f46efe9f09") } > db.deleteDemo.insertOne({"Name":"Robert"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd550682cba06f46efe9f0a") } > db.deleteDemo.insertOne({"Name":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd5506f2cba06f46efe9f0b") } > db.deleteDemo.insertOne({"Name":"Mike"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd550752cba06f46efe9f0c") } > db.deleteDemo.insertOne({"Name":"Bob"}); ... Read More

Get Depth of Root Node in a JTree with Java

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

443 Views

To get the depth of root node in a JTree in Java, use the getDepth() method. Let’s say our root node is “node”, therefore, we will get the depth of root node like this −node.getDepth();The following is an example to get the depth of root node −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Demo");       DefaultMutableTreeNode node = new DefaultMutableTreeNode("Website");       DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Videos"); DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Tutorials");       DefaultMutableTreeNode ... Read More

Check If Hidden Files Are Displayed in FileChooser in Java

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

101 Views

The result FALSE for is FileHidingEnabled() means the hidden files are displayed in the FileChooser. The following will display FALSE since file isn’t hidden −JFileChooser file = new JFileChooser(); file.setMultiSelectionEnabled(false); file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); file.setFileHidingEnabled(false); boolean res = file.isFileHidingEnabled();Above, at first, we have displayed the file by setting hidden to be FALSE −file.setFileHidingEnabled(false);The following is an example −Examplepackage my; import javax.swing.JFileChooser; public class SwingDemo {    public static void main(String[] args) {       JFileChooser file = new JFileChooser();       file.setMultiSelectionEnabled(false);       file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);       file.setFileHidingEnabled(false);       boolean res = file.isFileHidingEnabled();       System.out.println("File are ... Read More

Display Last Two Values from Field with MongoDB

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

96 Views

Let us first create a collection with documents −> db.numberOfValuesDemo.insertOne({"Values":[100,200,300,900,1000,98]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cefb736ef71edecf6a1f6ab") }Display all documents from a collection with the help of find() method −> db.numberOfValuesDemo.find().pretty();Output{    "_id" : ObjectId("5cefb736ef71edecf6a1f6ab"),    "Values" : [       100,       200,       300,       900,       1000,       98    ] }Following is the query to get the last two values.Here, we have used -ve sign under $slice −> db.numberOfValuesDemo.find({},{ "Values": { "$slice": -2 } } );Output{ "_id" : ObjectId("5cefb736ef71edecf6a1f6ab"), "Values" : [ 1000, 98 ] }

HTML Blockquote Cite Attribute

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

260 Views

The cite attribute of the element is used to set the source of a quotation. Following is the syntax −Above, url is the source of the quotation. Let us now see an example to implement the cite attribute of the element −Example Live Demo Magento Magento as stated on the official website:    Magento Commerce, part of Adobe Commerce Cloud, offers a one-of-a-kind eCommerce solution with enterprise power,       unlimited scalability, and open-source flexibility for B2C and B2B experiences.    Magento allows you to create unique, full-lifecycle customer experiences proven to generate more sales. ... Read More

Replace Number with String in MySQL Result Set

Rama Giri
Updated on 30-Jul-2019 22:30:26

484 Views

Yes, we can do that using the CASE statement. Let us first create a table −mysql> create table DemoTable    -> (    -> isMarried boolean    -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(true); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(false); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(false); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(true); Query OK, 1 row affected (0.19 sec)Display all records from the table ... Read More

Advertisements