i cNT GET ANSWER FOR THIS QUESTION

i cNT GET ANSWER FOR THIS QUESTION

The roots of the quadratic equation ax2+bx+c=0, aï??¹0 are given by the following formula: x=(-b?±â?š(b^2-4ac))/2a

In this formula. The term b2-4ac is called the discriminant . If b2-4ac=0, Then the equation has a single(repeated) root. If b2-4ac<0, the equation has two complex roots. Write a program that prompts the user to input the value of a(the coefficient of x2), b(the coefficient of x), and c (the constant term, and output the types of roots of the equation. Furthermore, if b2- 4ac â?¥ 0, the program should output the roots of the quadratic equation. (Hint: Use the method pow or sqrt from the class Math to calculate the square root.

View Answers

September 19, 2012 at 4:56 PM

Here is a java example that finds the roots of the quadratic equation.

import java.util.*;
class QuadraticEquation
{
public static void main(String[]args){
Scanner input=new Scanner(System.in);
System.out.print("Do you want to solve an equation (y/n): ");
String st=input.next();
if(st.equals("y")){
System.out.print("Enter the value of a: ");
double a=input.nextDouble();
System.out.print("Enter the value of b: ");
double b=input.nextDouble();
System.out.print("Enter the value of c: ");
double c=input.nextDouble();

double eq=b*b-4*a*c;
double r1= -b+Math.sqrt(eq);
double r2= -b-Math.sqrt(eq);
double Root1=r1/2*a;
double Root2=r2/2*a;
System.out.println("Root 1 ="+Root1);
System.out.println("Root 2 ="+Root2);
}
else{
System.exit(0);
}
}
}









Related Tutorials/Questions & Answers:
i cNT GET ANSWER FOR THIS QUESTION
i cNT GET ANSWER FOR THIS QUESTION  The roots of the quadratic equation ax2+bx+c=0, aï??¹0 are given by the following formula: x=(-b?±â?š(b^2-4ac))/2a In this formula. The term b2-4ac is called
i need to answer this Question but i can't do it probably
i need to answer this Question but i can't do it probably   use the web to locate the lyrics to the traditional song"The Twelve Days of Christmas" the song contains a list of gifts received for the holiday.the list is cumulative
Advertisements
share your answer to this question
share your answer to this question  i need to know what is the TELERIK CONTROL? what is the map suite? what is dunda chart? Also i have to know what... to search for the above mentioned topics and where i can get relevant information
java interview question and answer - Java Interview Questions
java interview question and answer   sir, i want one mark java interview question and answers
pls answer these question
pls answer these question  Write a program that prompts the user to input the length and width of a rectangle. Then calculate and prints the rectangle??s area and perimeter.   import java.io.*; class rectangle
question for "get method"
question for "get method"  when I want make method "get" for name or any char or string ..how I can write the syntax ? and what does it return
Please , can any one answer this Question?
Please , can any one answer this Question?  How to cummunicate one web application to another web application in different places
how to get following answer in turbo c program
how to get following answer in turbo c program  input 123456789 output 1 2 3 4 5 6 7 8 9
Java experts.Please answer this question - Java Beginners
Java experts.Please answer this question  class A { void get...("Success"); }} I want to know that is it true that 'a' refers to objects of all..., we get true for all cases,i.e.'a' refers to objects of A,C,D.If a refers o all
please i want someone to answer me pleeeeeeeeeeeeease...
please i want someone to answer me pleeeeeeeeeeeeease...    Write a JAVA program using 2D array to auto-grade exams. For a class of N students, your... answer key as Final Array in your program.( using 2D array
Clarify my last question's answer - Java Beginners
Clarify my last question's answer  Dear expert, I've tried out many times your solution but I'm not sure why it is not working. And I do not see how your solution is giving me the matching that I hope to do. Netbean Ide
help i want it now the answer pleas...
help i want it now the answer pleas...  write a program that will display the exactly output as below: Hints: declare and initialize value of array in double type.Read and write all elements of array.perform the multiply
Core Java Interview Question Page 3
as abstract method ? Answer: When i want child class to implement the behavior of the method. ADS_TO_REPLACE_1 Question: Can I call a abstract method from... Core Java Interview Question Page 3
ModuleNotFoundError: No module named 'okiti-cnt-to-cnt'
ModuleNotFoundError: No module named 'okiti-cnt-to-cnt'  Hi, My... named 'okiti-cnt-to-cnt' How to remove the ModuleNotFoundError: No module named 'okiti-cnt-to-cnt' error? Thanks   Hi, In your
how do i solve this question?
how do i solve this question?  1.Define a class named Circle with the following properties: a) An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier
how i can get jqfade.js library
how i can get jqfade.js library  how i can get jqfade.j script library
please help with the coding of this interface,i cnt seem to figure out codes for things to work here.realy nid them ASAP plz
please help with the coding of this interface,i cnt seem to figure out codes for things to work here.realy nid them ASAP plz  /* * To change this template, choose Tools | Templates * and open the template in the editor
please help with the coding of this interface,i cnt seem to figure out codes for things to work here.realy nid them ASAP plz
please help with the coding of this interface,i cnt seem to figure out codes for things to work here.realy nid them ASAP plz  /* * To change this template, choose Tools | Templates * and open the template in the editor
How do I get started with Bootstrap
How do I get started with Bootstrap  Hi, I am new to Bootstrap and want to learn it in. What all things I should know before starting Bootstrap? How do I get started with Bootstrap? Thanks
How do I get started with Bootstrap
How do I get started with Bootstrap  Hi, I am new to Bootstrap and want to learn it in. What all things I should know before starting Bootstrap? How do I get started with Bootstrap? Thanks
hi,i'am new to Jsp.Can some one please let me know an answer for this question?
hi,i'am new to Jsp.Can some one please let me know an answer for this question?  how do we upload an xml file and validate them against WIPO DTD
ModuleNotFoundError: No module named 'cnt'
ModuleNotFoundError: No module named 'cnt'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'cnt' How to remove the ModuleNotFoundError: No module named 'cnt' error
PureStack question---i dont know how to do this
PureStack question---i dont know how to do this  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from... the queue g. H and I join the queue h. G leaves the queue i. H and I leave
PureStack question---i dont know how to do this
PureStack question---i dont know how to do this  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from... the queue g. H and I join the queue h. G leaves the queue i. H and I leave
How can I get IBM certification for free?
How can I get IBM certification for free?  Hi, I am beginner in Data...: How can I get IBM certification for free? Try to provide me good examples or tutorials links so that I can learn the topic "How can I get IBM
How can I get into big data?
How can I get into big data?  Hi, I am beginner in Data Science... get into big data? Try to provide me good examples or tutorials links so that I can learn the topic "How can I get into big data?". Also tell me
How do I get a job in AI field?
How do I get a job in AI field?  Hi, I am beginner in Data Science... I get a job in AI field? Try to provide me good examples or tutorials links so that I can learn the topic "How do I get a job in AI field?". Also
Can I get a job with just python?
Can I get a job with just python?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Can I... so that I can learn the topic "Can I get a job with just python?"
How do I get a job in AI?
How do I get a job in AI?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How do I get... learn the topic "How do I get a job in AI?". Also tell me which
Can I learn Python at 45 and get a job?
Can I learn Python at 45 and get a job?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Can I learn Python at 45 and get a job? Try to provide me good examples
how i want to create a coding by this question?
how i want to create a coding by this question?  Design and write a class named Person and its two subclasses named Student and Employee. Make Lecturer and Admin subclasses of Employee. A person has a name, address, phone number
Question Answer
. If proper answer is not given you can ask question detailing about the previous... Question-Answer Guidelines... Here, you can post your desired question. For posting any question / query
I am getting error.How can i get details
I am getting error.How can i get details  Exception in thread "main" java.sql.SQLException: Listener refused the connecti n with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect
This is what i need in this Question - Java Beginners
This is what i need in this Question  You are to choose between two... explaination with out coding In my understanding I choose the non-empty array... array. so i need your help to know is it correct or wrong Thank you
I cant get values in MS acces in tables
I cant get values in MS acces in tables   I got problem in sending values from servlet . * i am using ms acces * i cant display my values but der... sta = con.createStatement(); int i=sta.executeUpdate("insert
I have posted a number of question but no one has answered?
I have posted a number of question but no one has answered?  No one has responded for ten days now. However my first question was answered on the same day. Is there a limit to the number of questions you can ask or am I doing
How can I get specific data from JSON
How can I get specific data from JSON  Hi, How can I get specific data from JSON? Thanks
Difficult Interview Questions Page -3
Answer: Always put a positive image of the company whether you have get... with the superiors. Question 24: When Were You Most Satisfied in Your Job?  Answer.... Question 26:  What is the most difficult situation you have faced? Answer
get UnsatisfiedLinkError when I try to use my JDBC driver.
get UnsatisfiedLinkError when I try to use my JDBC driver.  Why do I get UnsatisfiedLinkError when I try to use my JDBC driver
there are class A & class B.How can i get members of class A& B?
there are class A & class B.How can i get members of class A& B?  there are class A & class B.How can i get members of class A& B
If Sessin Contain Array how can i get each value.
If Sessin Contain Array how can i get each value.  sir, i m trying to get value form session and session contain array i mean .. whatever... to use this value in different conditions..so how can i get it.. Thank u
XML Interviews Question page19
namespaces? I don't know the answer to this question, but the likely reason... XML Interviews Question page19  ...;   How do I use prefixes to refer to element type and attribute
how i get experience wise resume from database when i submit from browser
how i get experience wise resume from database when i submit from browser  how i get experience wise resume from database when i submit from browser   Please go through the following link: Visit Here
How can I get query string values in JavaScript?
How can I get query string values in JavaScript?  How can I get query string values in JavaScript?   To get a query string value, you can use JQuery and JavaScript.. here is the code: function getParameterByName(name
How can I get the full URL with the attached parameters? - JSP-Servlet
How can I get the full URL with the attached parameters?  Hi, I'm trying to figure out how to get the current url and use it in my jsp page. I... call request.getURI() I get the following: http://localhost
i have a problem to do this question...pls help me..
i have a problem to do this question...pls help me..  Write a program... reversedNumber = 0; for (int i = 0; i <= num; i...; reversedNumber = reversedNumber * 10 + r; i = 0
Can I get a job with Google IT support professional certificate?
Can I get a job with Google IT support professional certificate?  Hi... for the tutorials to learn: Can I get a job with Google IT support professional... learn the topic "Can I get a job with Google IT support professional
How do I get a job as a data scientist in Bangalore?
How do I get a job as a data scientist in Bangalore?  Hi, I am... for the tutorials to learn: How do I get a job as a data scientist in Bangalore? Try... do I get a job as a data scientist in Bangalore?". Also tell me which
Where can I get best Data science training with project work?
Where can I get best Data science training with project work?  Hi, I... for the tutorials to learn: Where can I get best Data science training with project... the topic "Where can I get best Data science training with project work
How do I get a data science job with no experience?
How do I get a data science job with no experience?  Hi, I am... for the tutorials to learn: How do I get a data science job with no experience? Try to provide... do I get a data science job with no experience?". Also tell me which

Ads