Lakshmi Srinivas has Published 315 Articles

Java program to find the roots of a quadratic equation

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 21-Jun-2024 13:20:38

11K+ Views

Roots of a quadratic equation are determined by the following formula:$$x = \frac{-b\pm\sqrt[]{b^2-4ac}}{2a}$$Algorithm To calculate the rootsCalculate the determinant value (b*b)-(4*a*c).If determinant is greater than 0 roots are [-b +squareroot(determinant)]/2*a and [-b -squareroot(determinant)]/2*a.If determinant is equal to 0 root value is (-b+Math.sqrt(d))/(2*a)Example to find the roots of a quadratic equationBelow ... Read More

Java program to convert a Set to an array

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 21-Jun-2024 11:15:54

13K+ Views

The Set object provides a method known as toArray(). This method accepts an empty array as argument, converts the current Set to an array and places in the given array. To convert a Set object to an array − Create a Set object. Add elements to it. Create an empty array with size ... Read More

Java program to convert a list to an array

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 18-Jun-2024 16:02:05

17K+ Views

The List object provides a method known as toArray(). This method accepts an empty array as argument, converts the current list to an array and places in the given array. To convert a List object to an array − Create a List object. Add elements to it. Create an empty array with size ... Read More

Java program to find the sum of elements of an array

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 14-Jun-2024 14:12:56

44K+ Views

To find the sum of elements of an array.create an empty variable. (sum)Initialize it with 0 in a loop.Traverse through each element (or get each element from the user) add each element to sum.Print sum.Exampleimport java.util.Arrays; import java.util.Scanner; public class SumOfElementsOfAnArray {    public static void main(String args[]){     ... Read More

Java program to calculate the percentage

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 14-Jun-2024 13:37:08

28K+ Views

Percent means percent (hundreds), i.e., a ratio of the parts out of 100. The symbol of a percent is %. We generally count the percentage of marks obtained, return on investment etc. The percentage can go beyond 100% also.For Example, assuming that we have total and a part. So we ... Read More

How to use URL input type in HTML?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 21-Nov-2023 21:09:31

1K+ Views

The URL input type is used in HTML using the . Using this, allow users to add URL input type. On some browsers, the URL entered will be validated i.e. if you miss .com, while adding URL, then it won’t submit the form and will show an error i.e. “Please ... Read More

Java program to count the number of vowels in a given sentence

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 03-Nov-2023 03:21:12

26K+ Views

To count the number of vowels in a given sentence: Read a sentence from the user Create a variable (count) initialize it with 0; Compare each character in the sentence with the characters {'a', 'e', 'i', 'o', 'u' } If a match occurs increment the count. Finally print count. Example import java.util.Scanner; public class ... Read More

How to sum values of a Python dictionary?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 27-Aug-2023 13:33:15

26K+ Views

It is pretty easy to get the sum of values of a Python dictionary. You can first get the values in a list using the dict.values(). Then you can call the sum method to get the sum of these values. exampled = {    'foo': 10,    'bar': 20,    'baz': ... Read More

Is there a case when finally block does not execute in Java?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 10-Aug-2023 13:52:43

750 Views

Questions related to Java exception handling are most frequent during interviews for many companies and even in exams. One such question that an interviewer might ask is whether there is a case when the finally block does not execute in Java. We will try to find the answer to this ... Read More

How to avoid bugs in cloud computing

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 12-May-2022 12:30:51

201 Views

When the word cloud comes to our mind, we think of big white fluffy fantasy. But technically, cloud is the big white hard drive which stores bulky servers and all your information. It’s cool to think how someone else is managing everything and put the data whenever and wherever you ... Read More

1 2 3 4 5 ... 32 Next
Advertisements