Online quadratic equation calculator instance

Source: Internet
Author: User

Online quadratic equation calculator instance

Share the online mona1 quadratic equation calculator instance. For more information, see.

The Code is as follows:

<Html>

<Head>

<Meta http-equiv = "Content-Type" content = "text/html" charset = "UTF-8">

<Title> online mona1 quadratic equation calculator </title>

</Head>

<Body>

<Form name = "fquad">

<P align = "center"> solving quadratic equation calculation <br>

</P>

<Table align = "center">

<Tbody>

<Tr>

<Td bgcolor = "#990000">

<H2> <font color = "# ffffff"> <input size = "4" name = "fa" type = "text"> x <sup> 2 </sup> + <input size = "4" name = "fb" type = "text"> x + <input size = "4" name = "fc" type = "text"> = 0 <input onclick = "checkQuad () "type =" button "value =" problem solving "> <input type =" reset "value =" reset "> </font>

<P align = "center"> <font color = "# ffffff" face = "Arial"> <B> solution to a quadratic equation </B> </font> </ p>

</Td>

</Tr>

<Tr>

<Td bgcolor = "#990000">

<H2> <font color = "# ffffff"> x <sub> <a style = "text-decoration: none "> <font color =" # ffffff "> 1 </font> </a> </sub> = <input size =" 45 "name =" x1 "type = "text"> <br>

X <sub> 2 </sub> = <input size = "45" name = "x2" type = "text"> </font>

</Td>

</Tr>

<Tr>

 

</Tr>

</Tbody>

</Table>

</Form>

<P align = "center"> Made by CRoot </p>

<Script language = "JavaScript">

<! --

Var rootparti;

Var rootpart;

Var det;

Var rootparti1;

Var rootparti2;

Var;

Var B;

Var c;

Var x1;

Var x2;

Var I = "I ";

Function checkQuad (){

Var a = document. fquad. fa. value;

Var B = document. fquad. fb. value;

Var c = document. fquad. fc. value;

If (a = 0 & c! = 0 ){

X1 =-c/B;

X2 = "Not a quadratic equation, but here is your answer for x ";

Document. fquad. x1.value = x1;

Document. fquad. x2.value = x2;

}

Else if (a = "" & c! = 0 ){

X1 =-c/B;

X2 = "Not a quadratic equation ";

Document. fquad. x1.value = x1;

Document. fquad. x2.value = x2;

}

Else {

Quad ();

}

}

Function quad (){

Var a = document. fquad. fa. value;

Var B = document. fquad. fb. value;

Var c = document. fquad. fc. value;

Det = Math. pow (B, 2)-4 * a * c;

Rootpart = Math. sqrt (det)/(2 * );

Rootparti = (Math. sqrt (-det)/(2 * a) + I;

If (parseFloat (rootparti) <0 ){

Rootparti1 = rootparti;

Rootparti2 = (-1 * parseFloat (rootparti) + I;

}

Else {

Rootparti1 = (-1 * parseFloat (rootparti) + I;

Rootparti2 = rootparti;

}

If (rootparti1 = "1i "){

Rootparti1 = I;

Rootparti2 = "-I ";

}

Else if (rootparti1 = "-1i "){

Rootparti1 = "-I ";

Rootparti2 = I;

}

If (det = 0 ){

X1 = x2 =-B/(2 * );

}

Else if (det> 0 ){

X1 = (-B + Math. sqrt (det)/(2 * );

X2 = (-B-Math. sqrt (det)/(2 * );

}

Else if (-B/(2 * a) = 0 ){

X1 = rootparti1;

X2 = rootparti2;

}

Else {

X1 = (-B/(2 * a) + "+" + rootparti1 );

X2 = (-B/(2 * a) + "+" + rootparti2 );

}

Document. fquad. x1.value = x1;

Document. fquad. x2.value = x2;

}

// Will solve for complex numbers

 

// -->

</Script>

</Body>

</Html>

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.