Apply Modulus Operator to Floating Point Values in Java

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

809 Views

To apply modulus (%) operator to floating-point values in an effortless task. Let us see how.We have the following two values −double one = 9.7; double two = 1.2;Let us now apply the modulus operator −one % twoThe following is the complete example that displays the output as well −Example Live Demopublic class Demo { public static void main(String args[]) { double one = 9.7; double two = 1.2; System.out.println( one % two ); } }Output0.09999999999999964

Importance of Religion in Our Lives

Rashmi Iyer
Updated on 30-Jul-2019 22:30:24

25K+ Views

Religion today has taken a much-institutionalized form. Its origin has always been debated and discussed today by various scholars. In sociological terms, ‘Religion is a system of sacred belief and practices both in the tangible and intangible form’. Religion can serve the dual role of ideology as well as institution. Today, religion has assumed a more narrow-minded approach. However, understanding religion in the broad sense highlights the following important points about it in society:Cultural IdentityReligion plays a crucial role for a person in giving a cultural identity. Each religion has festivals, traditions, mythologies which form a part of the tangible ... Read More

Show Table Statement with Multiple LIKE Values in MySQL

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

545 Views

You can use WHERE clause and OR operator to show table with multiple LIKE. The syntax is as follows:show table from yourDatabaseName where tables_in_yourDatabaseName Like ‘%anyTableName%’ or tables_in_yourDatabaseName Like ‘%anyTableName2%’ or tables_in_yourDatabaseName Like ‘%anyTableName3%’ . . . . or tables_in_yourDatabaseName Like ‘%anyTableNameN%’In the above syntax, only the table name in the database is displayed.Here the database ‘test’ and the tables in the same database is considered. The query to show tables with multiple LIKE is as follows -mysql> show tables from test -> where tables_in_test like '%userrole%' -> or tables_in_test like '%view_student%' -> or tables_in_test like '%wholewordmatchdemo%';The following is the ... Read More

Print Initials of a Name with Last Name in Full Using Java

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

10K+ Views

When the full name is provided, the initials of the name are printed with the last name is printed in full. An example of this is given as follows −Full name = Amy Thomas Initials with surname is = A. ThomasA program that demonstrates this is given as follows −Example Live Demoimport java.util.*; public class Example {    public static void main(String[] args) {       String name = "John Matthew Adams";       System.out.println("The full name is: " + name);       System.out.print("Initials with surname is: ");       int len = name.length();       ... Read More

Select Non-Empty Column Values from MySQL

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

7K+ Views

Select non-empty column values using NOT IS NULL and TRIM() function. The syntax is as follows.SELECT * FROM yourTableName WHERE yourColumnName IS NOT NULL AND TRIM(yourColumnName) ' ';You can select non-empty value as well as whitespace from column using the same TRIM() function.To understand the syntax we discussed above, let us create a table. The query to create a table is as follows −mysql> create table SelectNonEmptyValues    -> (    -> Id int not null auto_increment,    -> Name varchar(30),    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.62 sec)Insert records in the table ... Read More

Literary Devices Used in English Literature

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

5K+ Views

Literary Devices are the peculiar structures used by writers in their works in order to convey their messages in a simple manner to the readers.The various literary devices used in English Literature areAlliteration, Analogy, Allegory, Anaphora, Metaphor, Simile, Aphorism, Oxymoron, Onomatopoeia, Eulogy, Elegy, and others.Alliteration: It is the device in which a number of words, having the same first consonant sound, occur close together in a series.Example- He had a haunting hat.Analogy: It is the comparison of an idea or a thing with another. Metaphors and similes are used to draw analogies. A metaphor is an implied comparison while a ... Read More

Measures to Conserve Water

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

906 Views

Water is a very important resource not only for us but also for our future generations. We should; therefore, save it in order to provide the maximum benefit to others. Water is necessary for our lives. So, if we save water, we save life.However, one must either not be aware of the ways to conserve it or may be reluctant thinking that such work will require a lot of toil. Let's talk about the ways in which water can be conserved.Turn off the Tap Post Use: While we brush our teeth, water keeps spilling out. It is necessary to close ... Read More

Auto-generate Database Diagram in MySQL

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

540 Views

To auto generate database diagram in MySQL, use MySQL workbench. For this, select the option from database as shown below −Database->Reverse EngineerHere is the snapshot showing the Database tab −After clicking “Database” above, choose the option “Reverse Engineer”. This state the “Reverse Engineer” mode.Clicking above will display the following table automatically. We had one table in the database “business”. The same table “tblstudent” is visible here −

Display Hour in 1-12 AM/PM Format in Java

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

297 Views

The h format in Java Date is like 1-12 hour in AM/ PM. Use SimpleDateFormat("h") to get the same format;// displaying hour in h format SimpleDateFormat simpleformat = new SimpleDateFormat("h"); String strHour = simpleformat.format(new Date()); System.out.println("Hour in h format = "+strHour);Above, we have used the SimpleDateFormat class, therefore the following package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More

Use UTC with MySQL NOW() and CURDATE() Functions

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

253 Views

To make MySQL’s NOW() and CURDATE() functions use UTC, you need to write my.cnf file. Write the below instruction in my.cnf −[mysqld_safe] timezone = UTCFirstly, reach the directory with the help of the following query −mysql> select @@datadir;The following is the output −+---------------------------------------------+ | @@datadir | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)Now reach the directory for which the link ... Read More

Advertisements