Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to find the roots of polynomial equation of 'n'th degree in java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Raghav Purankar
how to find the roots of polynomial equation of 'n'th degree in java
1 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners


i am new to java field and i wanted to find the roots of nth degree polynomial equation pls help me. thanks.


Advertisement
View Answers

May 9, 2011 at 12:40 PM


import java.util.*;
class FindRootsOfQuadraticEquation{
public static void main(String args[]) throws Exception{
double root,root1,root2;
Scanner input=new Scanner(System.in);
System.out.println("Quadratic Equation is ax2+bx+c");
System.out.println("Enter value of a");
int a=input.nextInt();
System.out.println("Enter value of b");
int b=input.nextInt();
System.out.println("Enter value of c");
int c=input.nextInt();
int d=(b*b)-(4*a*c);
if(d>0)
{
root1=(-b + Math.sqrt(d))/(2*a);
root2=(-b - Math.sqrt(d))/(2*a);
System.out.println("Roots are distinct");
System.out.println( root1 + "," + root2);
}
else if(d==0)
{
root=(-b)/(2*a);
System.out.println("Only one root is distinct");
System.out.println(root);
}
else if(d<0)
{
System.out.println("Roots are imaginary");
}
}
}


Related Tutorials/Questions & Answers:
how to find the roots of polynomial equation of 'n'th degree in java
how to find the roots of polynomial equation of 'n'th degree in java  i am new to java field and i wanted to find the roots of nth degree polynomial equation pls help me. thanks
Java find the roots of quadratic equation
Java find the roots of quadratic equation In this tutorial, you will learn how to find the roots of quadratic equation. Quadratic Equations are always.... And this program is implemented to find the roots of the quadratic equation. The given
Advertisements
Quadratic Equation - Java Beginners
Quadratic Equation  Write a program that will determine the roots... the corresponding equation, if it has a solution, or print an appropriate message... to solve an equation (y/n)? y Enter a: 1 Enter b: -5 Enter c: 6 Root1: 2.0
quadratic equation
quadratic equation  program to find roots of a quadratic equation...); System.out.println("Quadratic Equation is ax2+bx+c"); System.out.println("Enter value...))/(2*a); System.out.println("Roots are distinct"); System.out.println( root1
How to find hashtable size in Java?
How to find hashtable size in Java?  Hi, What is the code for Hashtable in Java? How to find hashtable size in Java? Give me the easy code. Thanks
How to find java jobs at any where in india
How to find java jobs at any where in india   Hi, I want information about java related jobs in india.where can i find that details
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26
How to use find method in Java - Java Beginners
How to use find method in Java  Hello, I want to write a class that gets a web page, parses it, and tries to find an object with certain properties. How can I do this? I was thinking, maybe get child objects of the browser
extract equation
extract equation  I want to extract equation from doc.   Hi Friend, Which equation you want to extract from the word document? Clarify this! Thanks
how to find largest number? - Java Interview Questions
how to find largest number?  this is my java coding: import...); } } i don't know how to add code to find the largest number.. please help...; yup yup.. i want to know how to find the greatest number that enter
Degree in Project Management
Degree in Project Management  What all Degree courses are available in Project Management? How to achieve Degree in Project Management? Thanks
Extarct equation
Extarct equation  Want to extarct equation of the form ax+by+c=0 from any word document.   Hi Friend, Try this: import java.io.*; import java.util.*; import org.apache.poi.hwpf.HWPFDocument; import
How to find version of Java installed on my computer? - Java Beginners
How to find version of Java installed on my computer?  How to get... with many more new features.How to find version of Java installed on my computer?To find out the version of Java installed on your computer, just type Java
Degree Converter
Degree Converter       In this example,  you will learn how to convert degree to Celsius, Celsius.... Code Description: In this program, you will also learn how to specify many
how to find the eigenvalue and eigenvector of n*n matrix in java
how to find the eigenvalue and eigenvector of n*n matrix in java  I m the new beginner in java and want to find eigenvalue and eigenvector of n*n matrix.where n is vary from n=4,5,6...... pls help me that would be appreciable
Extract Equation
Extract Equation  Hi Deepak I got your answer that how to extract equation.you said that it requires POI libray.how can i include it?I'm using Ecclipse. Thanks in advance.   Hi, To download the poi library, visit
Extract Equation
Extract Equation  Hi Deepak I got your answer that how to extract equation.you said that it requires POI libray.how can i include it?I'm using Ecclipse. Thanks in advance.   Hi, To download the poi library, visit
How to find unweighted Path with Less weighted path in java?
How to find unweighted Path with Less weighted path in java?  I have methods to find weighted and unweighted(Djistra) so I to output unweighted path that has less weighted cost...e.g if I have A->B->C and A->F->C
Extracting equation from any document
Extracting equation from any document  how can i extract equation from any word document?   Hello Friend, If you want to extract data from the word file, then visit the following link: Extract data from word document
How to find the size of a dynamic webpage using java... eg : Youtube........
How to find the size of a dynamic webpage using java... eg : Youtube........  package newpack; import java.io.BufferedInputStream; import...... Please help... Thanks, Ramit   the above code is running on JAVA
how to find inverse of n*n 2d array in java
how to find inverse of n*n 2d array in java  I reached upto code of printing the matrix as: Assume that matrix is square matrix where row=column code is: public class ReadContents{ public static void main(String args
find and replace in java
find and replace in java  Need 'find and replace' function in Java to find special keyword in XMl such as @,#,!,%..and replace with their corresponding entities
how to find the given date is sunday
how to find the given date is sunday  how to find the given date is sunday in java?   Hi Friend, Try the following code: import java.util.*; import java.text.*; class CheckDay{ public static void main(String
how to find jdk path in ubuntu?
how to find jdk path in ubuntu?  How to find out the path of installed jdk in ubuntu? Could anyone tell that command to execute from terminal.. Thanks
How to Find PHP version and configuration?
How to Find PHP version and configuration?  Find PHP version and configuration   If you want to find the version of PHP, you can just run...: http://www.phpzag.com/find-php-version-and-configuration
How to find run time in SQL.
How to find run time in SQL.  I have 10 backend jobs in sql which... 22/10/2010 17:30:00 I want to find the run time of both the jobs. (i.e when i run the query it should show me how long job has been running) Could you please
How to find a servlet object by name?
How to find a servlet object by name?  How can we locate a servlet object in the code by it's object name?   A. In web.xml you map servlet and define url pattern. Now this url-pattern is used for calling servlet. <
java find the error1
java find the error1  package com.test.dao; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DBConnections { public static String userName=""; public static String
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
Advertisements
 

 

 

DMCA.com