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
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
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
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
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
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
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
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  
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
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
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
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 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
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 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
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 can get jqfade.js library
how i can get jqfade.js library  how i can get jqfade.j script library
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
send answer
send answer  For online exam project,i want single question on single page and on that page there are three buttons previous,submit,next.If i click on next button it show next question from database
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
sir i,have a assignment for these question plz help me sir - JavaMail
sir i,have a assignment for these question plz help me sir  ...; } else { String str = " "; for (int i = 0; i <= top; i++) str = str + " " + arr[i]; System.out.println("Elements are " + str
Interview question link - Java Beginners
Interview question link  Hi, I want JAVA+J2EE interview question and answer please suggesion me link
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
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
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
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
java.please answer this...
java.please answer this...   Q1).How we can write a complete JAVA program that computes the following summation formulas..? â??_(i=1)^nâ??ã??i^2=ã?? (n^(2 ) ã??(n+1)ã??^2)/4
Question-Answer Guidelines
Question-Answer Guidelines How to ask questions..., if the answer is very complex, it will take 3-7 days and you will get the responding... of the question if the answer is too long to response. This process has been adopted
question
question  Dear sir i had some typing mistake at previous question so its my humble request to let me know the steps to start the tomcat6 under the tomcat directory
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
Please answer me - JSP-Servlet
Please answer me  Hello Guys, this is the third time I'm sending this question. But I've not got the right answer from you. The again is: I need java servlet or jsp codes that I can use to insert and retrieve image from MSSQL
Answer for SCJP Module-1 Question-13
Answer for SCJP Module-1 Question-13  The Answer for SCJP Module-1 Question-13 is missing , I think the answer is option '1', Correct me if I am wrong
question
question  i need a jsp program to get system ip address

Ads