//Import Scanner import java.util.Scanner; public class QuadraticCalculator { public static void main(String[] args) { //Title System.out.println("Welcome to use Quadratic Calculator "); //Scanner Scanner sc = new Scanner(System.in); //Insert Values System.out.print("Pleast enter the value a: "); double ValueA = sc.nextDouble(); System.out.print("Pleast enter the value b: "); double ValueB = sc.nextDouble(); System.out.print("Pleast enter the value c: "); double ValueC = sc.nextDouble(); //Disciminant double Disc = (ValueB * ValueB) - (4 * ValueA * ValueC); double QuadFormPlus = (-ValueB + Math.sqrt(Disc)) / (2 * ValueA); double QuadFormMinus = (-ValueB - Math.sqrt(Disc)) / (2 * ValueA); double QuadFormZero = -ValueB / (2 * ValueA); //Result more than zero if (Disc > 0) { System.out.println(""); } System.out.println("X1:" + QuadFormPlus); System.out.println("X2:" + QuadFormMinus); //Result equals zero if (Disc == 0) { System.out.println("X:"+ QuadFormZero); } //Math Error if (Disc < 0) { System.out.println("Math Error"); } } }
Subscribe to:
Post Comments (Atom)
If the answers is incorrect or not given, you can answer the above question in the comment box. If the answers is incorrect or not given, you can answer the above question in the comment box.