Cosine Calculator Using JavaScript with HTML Example

Hello Friends Today, through this tutorial, I will tell you How to Write Program Cosine calculator using JavaScript with HTML. Sure, here’s a simple example of a cosine calculator using JavaScript with HTML:

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cosine Calculator</title>
</head>
<body>
<h2>Cosine Calculator</h2>
<p>Enter an angle in degrees:</p>
<input type="number" id="angleInput" placeholder="Angle in degrees">
<button onclick="calculateCosine()">Calculate</button>
<p id="result"></p>

<script>
function calculateCosine() {

// Get the input value
var angleDegrees = document.getElementById("angleInput").value;

// Convert degrees to radians
var angleRadians = angleDegrees * Math.PI / 180;

// Calculate the cosine
var cosineValue = Math.cos(angleRadians);

// Display the result
document.getElementById("result").innerHTML = "Cosine of " + angleDegrees + " degrees is " + cosineValue.toFixed(4);
}
</script>
</body>
</html>

This code creates a simple webpage with an input field for the angle in degrees and a button to calculate the cosine of that angle. When the button is clicked, it triggers the `calculateCosine()` function, which retrieves the input value, converts it to radians, calculates the cosine using `Math.cos()`, and then displays the result on the page.

Example:-

Cosine Calculator

Enter an angle in degrees:

Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.