Smita Kapse has Published 558 Articles

C++ program to convert time from 12 hour to 24 hour format

Smita Kapse

Smita Kapse

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

912 Views

This is a C++ program to convert time from 12 hour to 24 hour format.AlgorithmBegin    In main(),    If median = pm       Check if entered hours is less than 12          Then add 12 to hours and print the time in 24 hours ... Read More

How do I know which MongoDB version is installed using the Command Line?

Smita Kapse

Smita Kapse

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

9K+ Views

First open the CMD and then reach the BIN directory of MongoDB. The screenshot to open CMD prompt is as follows.Above we have reached the RUN dialog by pressing START and then typing RUN and ENTER.Now, type CMD and press OK button to get the command line. The screenshot is ... Read More

Comparison of Exception Handling in C++ and Java

Smita Kapse

Smita Kapse

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

175 Views

The exception handling feature is present almost any object oriented languages nowadays. In C++ and Java also we can get this kind of feature. There are some similarities between exception handling in C++ and exception handling in Java, like in both languages we have to use the try-catch block. Though ... Read More

Java Program to insert styled text in a JTextPane Component

Smita Kapse

Smita Kapse

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

427 Views

Insert styled text in a JTextPane component using the SimpleAttributeSet and StyleConstants classes. With that, we will also use StyledDocument.The following is an example to insert styled text in a JTextPane component −package my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextPane; import javax.swing.text.BadLocationException; ... Read More

How to create a JLabel with an image icon in Java?

Smita Kapse

Smita Kapse

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

5K+ Views

Let us create a label with image icon −JLabel label = new JLabel("SUBJECT "); label.setIcon(new ImageIcon("E:ew.png"));Now, create another component −JTextArea text = new JTextArea(); text.setText("Add subject here...");Align the components with GridBagLayout −panel.setLayout(new GridBagLayout());The following is an example to center a label with an image icon −Examplepackage my; import java.awt.GridBagLayout; import ... Read More

C++ Program to Check if any Graph is Possible to be Constructed for a Given Degree Sequence

Smita Kapse

Smita Kapse

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

86 Views

It is a program to check possibility of construction of a graph in a given degree sequence.InputIt takes the no of edges and vertexes.OutputIt shows the random values of a created graph.AlgorithmsBegin    Declare a function RandomGraphs().       Declare NoEdge and NoVertex of the integer datatype and pass ... Read More

How to sum every field in a sub document of MongoDB?

Smita Kapse

Smita Kapse

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

315 Views

To sum every field in a sub document, use aggregate framework. Let us first create a collection with documents −> db.sumEveryFieldDemo.insertOne( ...    { ...       "_id":101, ...       "PlayerDetails": [ ...          {"PlayerName":"John", "PlayerScore":1000}, ...          {"PlayerName":"Carol", "PlayerScore":2000}, ...          {"PlayerName":"Sam", "PlayerScore":3000} ...    ... Read More

MongoDB to sort by subdocument match?

Smita Kapse

Smita Kapse

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

251 Views

To sort by sub-document match, you can use aggregate framework. Let us first create a collection with documents −> db.sortBySubDocumentsDemo.insertOne(    {       "StudentName": "Chris",       "StudentDetails": [          {             "Age":21,             ... Read More

Scope Resolution Operator Versus this pointer in C++?

Smita Kapse

Smita Kapse

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

204 Views

Here we will see some C++ examples and try to get what type of output will generate. Then we can understand the purpose and functions of scope resolution operator and the ‘this’ pointer in C++.If some code has some members say ‘x’, and we want to use another function that ... Read More

How to set the alignment of the JLabel content along the Y axis in Java?

Smita Kapse

Smita Kapse

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

395 Views

To set the alignment of the label content along the Y axis, use the setVerticalAlignment() method. Let us first set a label component. We have set the label background color as well so that we can check the alignment of the label’s content properly −JLabel label = new JLabel("Product Name ... Read More

Advertisements