
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7442 Articles for Java

2K+ Views
In this article, we will prompt the user to input an integer, and the entered value will be displayed back to them. To achieve this, we will use the Scanner class from java.util package, which allows us to read user input. Specifically, the nextInt() method of the Scanner class will be used to read the integer input from the user.Problem Statement Write a program in Java to accept an integer from the user and print itΒ β Input Enter an integer: 2 Output Given integer is :: 2 Steps to accept an integer from the user and print it Following are ... Read More

2K+ Views
In this article, we will prompt the user to input an integer, and the entered value will be displayed back to them. To achieve this, we will use the Scanner class from java.util package, which allows us to read user input. Specifically, the nextInt() method of the Scanner class will be used to read the integer input from the user.Problem Statement Write a program in Java to accept an integer from the user and print itΒ β Input Enter an integer: 2 Output Given integer is :: 2 Steps to accept an integer from the user and print it Following are ... Read More

14K+ Views
In this article, we will learn to find the roots of a quadratic equation using Java. The roots of a quadratic equation are determined by the following formula: $$x = \frac{-b\pm\sqrt[]{b^2-4ac}}{2a}$$ Here we will take input values for the coefficients π, π, and π of the quadratic equation π π₯ 2 + π π₯ + ... Read More

14K+ Views
In this article, we will learn to find the roots of a quadratic equation using Java. The roots of a quadratic equation are determined by the following formula: $$x = \frac{-b\pm\sqrt[]{b^2-4ac}}{2a}$$ Here we will take input values for the coefficients π, π, and π of the quadratic equation π π₯ 2 + π π₯ + ... Read More

686 Views
The java.lang.Math.round(float a) returns the closest int to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type int. Special cases βIf the argument is NaN, the result is 0.If the argument is negative infinity or any value less than or equal to the value of Integer.MIN_VALUE, the result is equal to the value of Integer.MIN_VALUE.If the argument is positive infinity or any value greater than or equal to the value of Integer.MAX_VALUE, the result is equal to the value of Integer.MAX_VALUE.Exampleimport java.util.Scanner; public class RoundingDecimalPlaces ... Read More

686 Views
The java.lang.Math.round(float a) returns the closest int to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type int. Special cases βIf the argument is NaN, the result is 0.If the argument is negative infinity or any value less than or equal to the value of Integer.MIN_VALUE, the result is equal to the value of Integer.MIN_VALUE.If the argument is positive infinity or any value greater than or equal to the value of Integer.MAX_VALUE, the result is equal to the value of Integer.MAX_VALUE.Exampleimport java.util.Scanner; public class RoundingDecimalPlaces ... Read More

3K+ Views
In this article, we will learn to swap two numbers using Java. We will use the Scanner class to get the user input and perform the swapping temporary variable. Read integers from users using the nextInt() method of the Scanner class. Steps to swap two integers Following are the steps to swap two numbers in Javaβ Import the Scanner class. Create a variable (temp), and initialize it with 0. Assign 1st number to temp. Assign the 2nd number to the 1st number. ... Read More

3K+ Views
In this article, we will learn to swap two numbers using Java. We will use the Scanner class to get the user input and perform the swapping temporary variable. Read integers from users using the nextInt() method of the Scanner class. Steps to swap two integers Following are the steps to swap two numbers in Javaβ Import the Scanner class. Create a variable (temp), and initialize it with 0. Assign 1st number to temp. Assign the 2nd number to the 1st number. ... Read More

3K+ Views
Read the base and exponent values from the user. Multiply the base number by itself and multiply the resultant with base (again) repeat this n times where n is the exponent value. 2 ^ 5 = 2 X 2 X 2 X 2 X 2 (5 times) Problem Statement Given a number, write a program in Java to calculate the power of the number β Input Enter the base number :: 12 Enter the exponent number :: 2 Output Result of 12 power 2 is 144 Steps to calculate the power of a number Import ... Read More

3K+ Views
Read the base and exponent values from the user. Multiply the base number by itself and multiply the resultant with base (again) repeat this n times where n is the exponent value. 2 ^ 5 = 2 X 2 X 2 X 2 X 2 (5 times) Problem Statement Given a number, write a program in Java to calculate the power of the number β Input Enter the base number :: 12 Enter the exponent number :: 2 Output Result of 12 power 2 is 144 Steps to calculate the power of a number Import ... Read More