Hong-Phuc Bui
2024-10-16 f8613c9ce2bd4b74b11727d2eae204f49151bcba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * quadratic-equation.js
 *
 */
 
import {terminal} from "./dfhi.js";
 
window.main = function(...argv) {
    let a = Number(argv[0]),
        b = Number(argv[1]),
        c = Number(argv[2]);
    let delta = b*b - 4*a*c;
    let d = Math.sqrt(delta);
    let x1 = (-b + d) / (2*a),
        x2 = (-b - d) / (2*a);
    
    terminal.printl(`Equation: ${a}x^2 + (${b})x + (${c})`);
    terminal.printl(`first solution: ${x1}`);
    terminal.printl(`second solution: ${x2}`);
};