Created
August 26, 2016 17:07
-
-
Save c650/e5cb7069750d4504cafaeba4c88e7bb4 to your computer and use it in GitHub Desktop.
CLI Quadratic Formula Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Quadratic { | |
public static void main(String[] args) { | |
double a,b,c; | |
if (args.length != 3) { | |
System.out.println("Wrong number of Args.\nUsage: [a] [b] [c]"); | |
System.exit(1); | |
} | |
a = Double.parseDouble(args[0]); | |
b = Double.parseDouble(args[1]); | |
c = Double.parseDouble(args[2]); | |
System.out.println( "Solution 1: " + (-b + Math.sqrt( b * b - (4 * a * c) )) / ( 2 * a ) ); | |
System.out.println( "Solution 2: " + (-b - Math.sqrt( b * b - (4 * a * c) )) / ( 2 * a ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment