Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <script>
- ans = 'y'
- while (ans == 'y') {
- b = parseFloat(prompt("b = "))
- c = parseFloat(prompt("c = "))
- d = b * b - 4 * c
- if (d < 0)
- document.writeln("No solution")
- else {
- x_1 = (-b + Math.sqrt(d)) / 2
- x_2 = (-b - Math.sqrt(d)) / 2
- }
- document.writeln('x' + '<sub>1</sub>' + ' = ' + x_1 + '<br>')
- document.writeln('x' + '<sub>2</sub>' + ' = ' + x_2 + '<br>')
- ans = prompt("Repeat? [y/n]")
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment