This example demonstrate about How to set an Android notification to a specific date in the future.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.AlarmManager ; import android.app.DatePickerDialog ; import android.app.Notification ; import android.app.PendingIntent ; import android.content.Context ; import android.content.Intent ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.Button ; import android.widget.DatePicker ; ... Read More
Limited Contention Protocols are the media access control (MAC) protocols that combines the advantages of collision based protocols and collision free protocols. They behave like slotted ALOHA under light loads and bitmap protocols under heavy loads.ConceptIn computer networks, when more than one station tries to transmit simultaneously via a shared channel, the transmitted data is garbled, an event called collision. In collision based protocols like ALOHA, all stations are permitted to transmit a frame without trying to detect whether the transmission channel is idle or busy. In slotted ALOHA, the shared channel is divided into a number of discrete time ... Read More
To position components at the top fo the grid cell, set the GridBagConstraints. Let’s say we have a panel and within that two CheckBox components −JPanel panel1 = new JPanel(new GridBagLayout()); JCheckBox checkBox1 = new JCheckBox("Undergraduate"); JCheckBox checkBox2 = new JCheckBox("Graduate");Position the components now −panel1.add(checkBox1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.NORTH, new Insets(0, 0, 0, 0), 0, 0)); panel1.add(checkBox2, new GridBagConstraints(1, 0, 1, 1, 2.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NORTH, new Insets(0, 0, 0, 0), 0, 0));The following is an example to position component at the top of the grid cell with GridBagLayout −Examplepackage my; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; ... Read More
In a PHP application, we are working with data in various formats such as string, array, objects or more...In a real-time application, we may need to read a php object result in the form of an associative array to get the desired output.So we will discuss here how to transform a php object to an associative array in PHP.Let's explain what is an object and associative array in PHP? An object is an instance of a class meaning that from one class you can create many objects. It is simply a specimen of a class and has memory allocated. While ... Read More
The name attribute of the element is used to set the name for a button. More than one button can have the same name, but we can submit different values from these buttons using the name attribute.Following is the syntax −Above, btn_name is the name of the button. Let us now see an example to implement the name attribute if the element −Example Live Demo Get the details of the employee: Address Phone Appraisal % OutputIn the above example, different values will ... Read More
Initially, till Java6 it is needed to register the driver using Class.forname() or the registerDriver() method before establishing connection with the database.But, since Java 1.6, JDBC 4.0 API, there is no need to register the driver explicitly, You Just need to set the Class path for the JDBC 4.X driver, Java automatically detects the Driver class and loads it.ExampleIn the following JDBC program we are trying connect with MySQL database first of all include the dependency for the MySQL driver in the pom.xml of your project. mysql mysql-connector-java 8.0.16 Then, without registering the MySQL driver class com.mysql.jdbc.Driver ... Read More
To generate a sum triangle of a given arrayGet the elements of the array from the user say, myArray[n].Create a two dimensional array say, result[n][n].Store the contents of the given array in the first row from bottom of the 2D array.result[n][i] = myArray[i].Now, from the second row of the 2D array fill elements such that ith element in each row is the sum of ith and (i+1)st elements of the previous row.result[i][j] = result[i+1][j] + result[i+1][j+1];Example Live Demoimport java.util.Scanner; public class SumTriangleOfAnArray { public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter ... Read More
Here we will see the ASCII NUL, ASCII 0 and the Numeric Literal 0. The ASCII null is represented as 0x00, and zero is represented as 0x30. The ASCII NUL character is used to denote the end of the string in C or C++. When programmer used ‘0’ (character 0) it is treated as 0x30. This is a hexadecimal number. The decimal equivalent is 48. To put ASCII NUL we have to mention ‘\0’ instead of ‘0’.char asciiNul = ‘\0’; int zero = 0; char zeroChar = ‘0’;The first one is ASCII NUL, second one is numeric 0, and the third one is character 0.
Here we will see how to generate random numbers, which are following in a normal distribution. For the normal random, the formula is like below.𝑧 = √−2 ln 𝑥1 cos (2𝜋𝑥2)Here x1 and x2 are chosen randomly.Example#include #include #include #include using namespace std; double rand_gen() { // return a uniformly distributed random value return ( (double)(rand()) + 1. )/( (double)(RAND_MAX) + 1. ); } double normalRandom() { // return a normally distributed random value double v1=rand_gen(); double v2=rand_gen(); return cos(2*3.14*v2)*sqrt(-2.*log(v1)); } main() { double sigma = 82.0; double Mi = 40.0; for(int i=0;i
The all important The FTP class in ftplib module implements the client side of the FTP protocol.To establish connection with a FTP server, obtain FTP object.con=FTP(hostname)The FTP class supports following methods −connect()Connect to the given host and port. The default port number is 21, as specified by the FTP protocol specification.Getwelcome()Return the welcome message sent by the server in reply to the initial connection.login(user='anonymous', passwd='', acct='')Log in as the given user. The passwd and acct parameters are optional and default to the empty string. If no user is specified, it defaults to 'anonymous'. If user is 'anonymous', the default passwd ... Read More