diff --git a/.idea/misc.xml b/.idea/misc.xml index 639900d..69ace3f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Java-Assignment-005.iml b/Java-Assignment-005.iml index b46c0dd..e1006ff 100644 --- a/Java-Assignment-005.iml +++ b/Java-Assignment-005.iml @@ -5,6 +5,7 @@ + \ No newline at end of file diff --git a/src/Quadratic.java b/src/Quadratic.java new file mode 100644 index 0000000..a143f43 --- /dev/null +++ b/src/Quadratic.java @@ -0,0 +1,34 @@ +/** + * @author Tanner Wilson + * @version 1.0 + */ + +import java.util.Scanner; + +public class Quadratic { + public static void main(String[] args){ + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter the value of a: "); + int a = scanner.nextInt(); + + System.out.print("Enter the value of b: "); + int b = scanner.nextInt(); + + System.out.print("Enter the value of c: "); + int c = scanner.nextInt(); + + double discriminant = b * b - 4 * a * c; + + if (discriminant > 0) { + double root1 = (-b + Math.sqrt(discriminant)) / (2 * a); + double root2 = (-b - Math.sqrt(discriminant)) / (2 * a); + System.out.println("Two distinct real roots: " + root1 + " and " + root2); + } else if (discriminant == 0) { + double root = -b / (2 * a); + System.out.println("One real root: " + root); + } else { + System.out.println("No real roots, discriminant is negative"); + } + } +} \ No newline at end of file