83% Tue Apr 25 7:45:41 PM Q e E Chrome File Edit View History Bookmarks People W
ID: 3825892 • Letter: 8
Question
83% Tue Apr 25 7:45:41 PM Q e E Chrome File Edit View History Bookmarks People Window Help YouTube's Adpocalyp x Grades-Professiona x Lab 13.pdf X C Computer Science qu X New Tab C C ksuweb.kennesaw.edu hhaddad/Spring2017/CS1301/Lab13.pd Apps D cs 1301: Program.. YouTube home e CompTIA A+ Certifi IowILink online Ca M Inbox king199 PlayStation Vue height. 6:04 C: 5 Lab 13.pdf Write a test Exercise 3: Following the instructions in the problem statement, design and implement a Java program for height 40 programming exercise 9.10, page 363 (name it QuadraticEquation.java). Next, develop a test program in ght, area, a separate file (call it ava) as instructed in the problem statement Section 9.2, Instructions: 1. Programs must be working correctly es the stock 2. Programs must be completed and checked before working assignment #13. 3. Programs must be checked by the end of the designated lab session. rice for the ge changed. Write a test the name new current its elapsed 00000000, e using the Page 1 of 1 e Chicken WireExplanation / Answer
class QuatradicEquation
{
public QuatradicEquation(int a,int b,int c)
{
System.out.println("Given quadratic equation:"+a+"x^2 + "+b+"x + "+c);
double d =getDiscriminant(a,b,c);
if(d > 0)
{
System.out.println("Roots are real and unequal");
double root1 =getRoot1(a,b,d);
double root2 =getRoot2(a,b,d);
System.out.println("First root is:"+root1);
System.out.println("Second root is:"+root2);
}
else if(d == 0)
{
System.out.println("Roots are real and equal");
double root1 =getRoot1(a,b,d);
System.out.println("Root:"+root1);
}
else
{
System.out.println("Roots are imaginary");
}
}
double getDiscriminant(int a,int b,int c)
{
double d = b * b - 4 * a * c;
return d;
}
double getRoot1(int a,int b,double d)
{
double root1= ( - b + Math.sqrt(d))/(2*a);
return root1;
}
double getRoot2(int a,int b,double d)
{
double root2= (-b - Math.sqrt(d))/(2*a);
return root2;
}
}
class TestQuatradicEqation
{
public static void main(String args[])
{
QuatradicEquation a=new QuatradicEquation(2,3,1);
}
}
Output:-
C:Users ajendraDocumentscheggjava>javac TestQuatradicEqation.java
C:Users ajendraDocumentscheggjava>java TestQuatradicEqation
Given quadratic equation:2x^2 + 3x + 1
Roots are real and unequal
First root is:-0.5
Second root is:-1.0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.