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..f712bd8 --- /dev/null +++ b/src/Quadratic.java @@ -0,0 +1,30 @@ +/** + * @author Jenny Li + * @version 1.0 + * date: 2/25/24 + */ +import java.util.Scanner; +public class Quadratic { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + //input value for a + System.out.print("Enter a value for a: "); + double a = in.nextDouble(); + //input value for b + System.out.print("Enter a value for b: "); + double b = in.nextDouble(); + //input value for c + System.out.print("Enter a value for c: "); + double c = in.nextDouble(); + //quadratic formula + double d = b*b - 4.0*a*c; + + if(d==0.0) { + double s1 = -b / (2.0*a); + System.out.println("The only solution is " + s1); + } + else { + System.out.println("There are no real solutions or there are multiple solutions."); + } + } +}