Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>funkcja kwadratowa JS</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- <meta charset="UTF-8">
- <script type="text/javascript">
- function obliczanie()
- {
- var a,b,c;
- var x1,x2;
- a = document.getElementById("a").value;
- b = document.getElementById("b").value;
- c = document.getElementById("c").value;
- if (a==0)
- {
- if (b==0)
- {
- document.write("Równanie liniowe bez rozwiązań");
- }
- else
- {
- x1= -c/b;
- document.write("Jedno rozwiązanie:<br> x=" + x1);
- }
- }
- else
- {
- var delta=b*b-4*a*c;
- if (delta<0)
- {
- document.write("Równanie kwadratowe bez rozwiązań");
- }
- else if (delta==0)
- {
- x1= -b/2*a;
- document.write("Jedno rozwiązanie:<br> x1=" + x1);
- }
- else
- {
- x1 = (-b+Math.sqrt(delta))/2*a;
- x2 = (-b-Math.sqrt(delta))/2*a;
- document.write("Dwa rozwiązania:<br> x1=" + x1 + "<br>x2=" + x2);
- }
- }
- }
- </script>
- </head>
- <body>
- Wpisz kolejno a, b, c:
- <form onsubmit="obliczanie(); return false">
- <input type="text" width id="a"><br>
- <input type="text" id="b"><br>
- <input type="text" id="c"><br>
- <input type="submit" value="Rozwiąż">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement