Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="bg">
- <head>
- <meta charset="UTF-8">
- <title>Лице на кръг</title>
- </head>
- <body>
- <h2>Калкулатор за лице на кръг</h2>
- <label for="r">Въведете радиус:</label>
- <input type="number" id="r"><br><br>
- <button onclick="circleArea()">Изчисли</button>
- <button onclick="clearValue()">Изчисти</button>
- <p id="result"></p>
- <script>
- function circleArea() {
- let r = parseFloat(document.getElementById("r").value);
- let S = Math.PI * Math.pow(r, 2);
- if (r !== null && r !== " " && r > 0)
- document.getElementById("result").innerHTML = "Лицето на кръга е " + S.toFixed(4) + ".";
- else
- document.getElementById("result").innerHTML = "Грешна стойност на радиус!";
- }
- function clearValue() {
- document.getElementById("r").value = "";
- document.getElementById("result").innerHTML = "";
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment