Find All Angles of a Triangle in Java

Venkata Sai
Updated on 30-Jul-2019 22:30:26

604 Views

To find the angles of a triangle we can use sin/cosine rules according to cosine rule −cos A = (b^2 + c^2 - a^2)/2bcwhere A, B , C are the vertices and a, b, c are the sides of the given triangle then, angles of the triangle when the sides a, b, c given are −angleAtA = acos((b^2 + c^2 - a^2)/(2bc)) angleAtB = acos((a^2 + c^2 - b^2)/(2ac)) angleAtC = acos((a^2 + b^2 - c^2)/(2ab))

Mouse and Keyboard Automation Using Python

Chandu yadav
Updated on 30-Jul-2019 22:30:26

2K+ Views

In this section, we’ll try to automate the movements of mouse and keyboard using pyautogui module in python.Pyautogui is a library that allows you to control the mouse and keyboard to do various things.It  is a cross-platform GUI automation Python module for human beings.As it is a third party library, we need to install it.pip install pyautoguiMouseBelow is program to automate the movement of your mouse. On running your programme, you can see the mouse movement with every command. I run below command on CLI so as to capture the mouse movement. You can try with others different values too.Example>>> ... Read More

Set Minimum Size Limit for a JFrame in Java

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

3K+ Views

Use the setMinimumSize() method to set the minimum size limit for a JFrame −JFrame frame = new JFrame(); frame.setMinimumSize(new Dimension(500, 300));The following is an example to set minimum size limit for a JFrame −Exampleimport java.awt.Color; import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame();       JButton button = new JButton("Close!");       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       frame.setContentPane(button);       button.addActionListener(e -> {          frame.dispose();       });       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       frame.setMinimumSize(new Dimension(500, ... Read More

Add Extra New Notification When Push Notification is Received in Android App

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

357 Views

This example demonstrate about How to add an extra new notification when push notification received in Android App.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.     Step 3 − 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.Toast ; public class MainActivity extends AppCompatActivity {    public static final String NOTIFICATION_CHANNEL_ID = "10001" ... Read More

Selecting a Single Field from MongoDB

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

483 Views

You can use $and operator. Let us first create a collection with documents −>db.selectingASingleFieldDemo.insertOne({"StudentFirstName":"John", "StudentAge":23, "StudentCountryName":"US"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd547142cba06f46efe9f02") } >db.selectingASingleFieldDemo.insertOne({"StudentFirstName":"Carol", "StudentAge":21, "StudentCountryName":"UK"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd5471f2cba06f46efe9f03") } >db.selectingASingleFieldDemo.insertOne({"StudentFirstName":"David", "StudentAge":24, "StudentCountryName":"AUS"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd5472c2cba06f46efe9f04") } >db.selectingASingleFieldDemo.insertOne({"StudentFirstName":"Robert", "StudentAge":26, "StudentCountryName":"AUS"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd548382cba06f46efe9f05") }Following is the query to display all documents from a collection with the help of find() method −> db.selectingASingleFieldDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd547142cba06f46efe9f02"),    "StudentFirstName" : "John",    "StudentAge" : ... Read More

Set Location of JLabel in a JFrame with Java

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

8K+ Views

To set location of a component in a JFrame, use the setBounds() method. Let us first create a frame and a panel −JFrame frame = new JFrame("Demo Frame"); JPanel panel = new JPanel(); frame.getContentPane();Create a component i.e. label and set the dimensions using setBounds(). Here, you can set the location in the form of x and y coordinates −JLabel label = new JLabel("Demo Label!"); Dimension size = label.getPreferredSize(); label.setBounds(150, 100, size.width, size.height);The following is an example to set location of a label in a JFrame −Examplepackage my; import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.WindowConstants; public ... Read More

Set JSlider Vertical and Move Bottom to Top in Java

Chandu yadav
Updated on 30-Jul-2019 22:30:26

115 Views

To set the JSlider vertical, use the VERTICAL constant while creating the slider. Let us create a new Slider −JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 60);The other parameter values set above allows you to include the minimum, maximum and the initial value of the slider.The following is an example to set the slider vertical and move bottom-to-top −Examplepackage my; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.WindowConstants; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Frame with Slider");       JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 60); ... Read More

MongoDB Query to Get Last Inserted Document

Chandu yadav
Updated on 30-Jul-2019 22:30:26

14K+ Views

To get last inserted document, use sort() along with limit(1).Let us first create a collection with documents −> db.getLastInsertedDocument.insertOne({"Name":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cefb17eef71edecf6a1f6a8") } > db.getLastInsertedDocument.insertOne({"Name":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cefb181ef71edecf6a1f6a9") } > db.getLastInsertedDocument.insertOne({"Name":"Robert"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cefb185ef71edecf6a1f6aa") }Display all documents from a collection with the help of find() method −> db.getLastInsertedDocument.find();Output{ "_id" : ObjectId("5cefb17eef71edecf6a1f6a8"), "Name" : "John" } { "_id" : ObjectId("5cefb181ef71edecf6a1f6a9"), "Name" : "Chris" } { "_id" : ObjectId("5cefb185ef71edecf6a1f6aa"), "Name" : "Robert" }Following is the query to get last inserted document −> db.getLastInsertedDocument.find({}).sort({_id:-1}).limit(1);Output{ "_id" ... Read More

Sum Time in MySQL by Converting into Seconds

Kumar Varma
Updated on 30-Jul-2019 22:30:26

2K+ Views

To convert time to seconds, use the TIME_TO_SEC() method. Let us first create a table −mysql> create table DemoTable    -> (    -> ArrivalTime time    -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('04:10:00'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('05:20:50'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('06:40:10'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+-------------+ | ArrivalTime | +-------------+ | 04:10:00 ... Read More

Java Programs for Printing Pyramid Patterns of Numbers

Venkata Sai
Updated on 30-Jul-2019 22:30:26

263 Views

Following is a Java program which prints a pyramid of numbers.Example Live Demopublic class PrintingPyramids {    public static void main(String args[]){       int n,i,j,k=1;       n = 5;       for(i = 0; i

Advertisements