- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 9326 Articles for Object Oriented Programming
777 Views
In this article, we will understand how to find the perimeter of a rectangle. The Perimeter of a rectangle is calculated by adding the lengths of all the sides of the rectangle.Below is a demonstration of a rectangle. The perimeter of a rectangle is the total length of the two lengths and two widths of the rectangle −InputSuppose our input is −The length of the sides of a rectangle are : 5, 8, 5, 8OutputThe desired output would be −Perimeter : 26 AlgorithmStep 1 – START Step 2 – Declare 5 floating point variables a, b, c, d and perimeter ... Read More
13K+ Views
In this article, we will understand how to calculate the Compound interest. Compound Interest is calculated using the following formula −Principle*(1+(rate / 100))^time – PrincipleCompound Interest − The percentage interest charged on principal and accrued interest. Rates are higher compared to Simple Interest.Below is a demonstration of the same −InputSuppose our input is −Enter a Principle number : 100000 Enter Interest rate : 5 Enter a Time period in years : 3OutputThe desired output would be −The Compound Interest is : 15762.50000000001AlgorithmStep 1 – START Step 2 – Declare four float values principle, rate, time, compound_interest Step 3 – Read ... Read More
2K+ Views
The agenda of this article is to write a Java program to calculate simple interest. But, before doing it programmatically, let's understand how we calculate simple interest mathematically. The simple interest is a technique to determine the amount of interest gained on a principal amount at the specified interest rate for a given time period. Unlike compound interest, its principal amount does not change over time. To calculate Simple Interest, we use the following formula − Simple Interest (S.I) = Principal * Time * Rate / 100 Below is a demonstration of the same − Input Enter a Principle ... Read More
3K+ Views
In this article, we will understand how to find even sum of Fibonacci Series till number N. A Fibonacci series is sequence of numbers formed by the sum of its two previous integers. An even Fibonacci series is all the even numbers of the Fibonacci series.Fibonacci series generates the subsequent number by adding two previous numbers. Fibonacci series starts from two numbers − F0 & F1. The initial values of F0 & F1 can be taken 0, 1 or 1, 1 respectively.Fn = Fn-1 + Fn-2Hence, a Fibonacci series can look like this −F8 = 0 1 1 2 3 ... Read More
962 Views
In this article, we will understand how to check whether the input number is a neon number. A neon number is such a number whose sum of digits of square of the number is equal to the number.Below is a demonstration of the same −InputSuppose our input is −9OutputThe desired output would be the following because 92 = 81 i.e. 8 + 1 = 9The given input is a neon number AlgorithmStep1- Start Step 2- Declare an integers my_input Step 3- Prompt the user to enter an integer value/ Hardcode the integer Step 4- Read the values Step 5- Compute ... Read More
9K+ Views
In this article, we will understand how to print alphabets from A to Z or a to z in Java. This is accomplished using a simple for loop.Below is a demonstration of the same −InputSuppose our input is −A to ZOutputThe desired output would be −A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AlgorithmStep1- Start Step 2- Declare a character: my_temp Step 3- Run a for loop from A to Z and print the values using the increment operator Step 4- Display ... Read More
29K+ Views
In this article, we will understand how to display all the prime numbers from 1 to N in Java. All possible positive numbers from 1 to infinity are called natural numbers. Prime numbers are special numbers who have only two factors 1 and itself and cannot be divided by any other number.A number is a prime number if its only factors are 1 and itself. 11 is a prime number. Its factors are 1 and 11 itself. Some examples of prime numbers are 2, 3, 5, 7, 11, 13 and so on. 2 is the only even prime number. All ... Read More
2K+ Views
In this article, we will understand how to add two complex numbers in Java. They have the ‘I’ that is, an imaginary part associated with it.Below is a demonstration of the same −InputSuppose our input is −15 +i24 and 3 +i7OutputThe desired output would be −18 +i31 AlgorithmStep1- Start Step 2- Declare three Complex numbers: my_input_1, my_input_2 and my_result Step 3- Hardcode the complex number values Step 4- Define a function add_complex_number when u add the real numbers and the imaginary numbers separately and return the result. Step 5- Store the result in my_result variable. Step 6- Display the result ... Read More
3K+ Views
In this article, we will understand how to add two binary strings in Java. A binary string is a sequence of numbers represented in bytes 0s and 1s.Below is a demonstration of the same −InputSuppose our input is −10101 10001OutputThe desired output would be −100110 AlgorithmStep 1- START Step 2- Create new scanner object Step 3- Enter two binary inputs Step 4- Define a carry flag Step 5- Use while condition to check if they are equal to 0 Step 6- If not, use the % operator and the carry flag to perform bitwise addition Step 7-Display it as result ... Read More
2K+ Views
In this article, we will understand how to get an input from user in Java. This achieved using a scanner object. The Scanner.nextInt() method is used to get the input.The java.util.Scanner.nextInt() method Scans the next token of the input as an int. An invocation of this method of the form nextInt() behaves in exactly the same way as the invocation nextInt(radix), where radix is the default radix of this scanner.Below is a demonstration of the same −InputSuppose our input is −Hello, I am John!OutputThe desired output would be −The input string is: Hello, I am John! AlgorithmStep1- Start Step 2- ... Read More