-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tangent Formula Calculator and Height Unit option in BMI Calcul…
…ator (#1850)
- Loading branch information
Showing
11 changed files
with
361 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,4 +347,4 @@ button.calculate:hover { | |
.linkDownload { | ||
display: none; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# <p align="center">Tangent Formula Calculator</p> | ||
|
||
## Description :- | ||
|
||
Calculates the tangent angle of a triangle. | ||
|
||
## Tech Stacks :- | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
|
||
## Screenshots :- | ||
|
||
![image](https://github.com/user-attachments/assets/46cececf-442d-4bda-add4-cee006035922) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Tangent Formula Calculator</title> | ||
</head> | ||
|
||
<body> | ||
<header> | ||
<h1>Tangent Formula Calculator</h1> | ||
</header> | ||
|
||
<section id="calculator"> | ||
<label for="firstSide">First Side (a):</label> | ||
<input type="number" id="firstSide" required placeholder="Enter (a)"> | ||
|
||
<label for="secondSide">Second Side (b):</label> | ||
<input type="number" id="secondSide" required placeholder="Enter (b)"> | ||
|
||
<label for="thirdSide">Third Side (c):</label> | ||
<input type="number" id="thirdSide" required placeholder="Enter (c)"> | ||
|
||
<label for="calculationType">Choose Angle:</label> | ||
<select id="calculationType"> | ||
<option value="TanA">TanA</option> | ||
<option value="TanB">TanB</option> | ||
<option value="TanC">TanC</option> | ||
</select> | ||
|
||
<button onclick="calculate()">Calculate</button> | ||
|
||
<p id="result"></p> | ||
</section> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
function calculate() { | ||
// Get input values | ||
const firstSide = parseFloat(document.getElementById('firstSide').value); | ||
const secondSide = parseFloat(document.getElementById('secondSide').value); | ||
const thirdSide = parseFloat(document.getElementById('thirdSide').value); | ||
const calculationType = document.getElementById('calculationType').value; | ||
|
||
const a = firstSide; | ||
const b = secondSide; | ||
const c = thirdSide; | ||
|
||
if (isNaN(a) || isNaN(b) || isNaN(c)) { | ||
document.getElementById("result").innerText = "Please enter valid numbers for all fields."; | ||
return; | ||
} | ||
|
||
// Perform the selected calculation | ||
let result; | ||
if (calculationType === 'TanA') { | ||
// Calculate the tangent of angle A | ||
result = calculateTanA(firstSide, secondSide, thirdSide); | ||
} else if (calculationType === 'TanB') { | ||
// Calculate the tangent of angle B | ||
result = calculateTanB(firstSide, secondSide, thirdSide); | ||
} else if (calculationType === 'TanC') { | ||
// Calculate the tangent of angle C | ||
result = calculateTanC(firstSide, secondSide, thirdSide); | ||
} | ||
|
||
// Display the result | ||
const resultElement = document.getElementById('result'); | ||
resultElement.textContent = result; | ||
} | ||
|
||
function calculateTanA(firstSide, secondSide, thirdSide) { | ||
const a = firstSide; | ||
const b = secondSide; | ||
const c = thirdSide; | ||
const cosA = (((b * b) + (c * c) - (a * a)) / (2 * b * c)); | ||
const sinA = Math.sqrt(1 - cosA * cosA); | ||
return `The value of TanA is: ${sinA / cosA}`; | ||
} | ||
|
||
function calculateTanB(firstSide, secondSide, thirdSide) { | ||
const a = firstSide; | ||
const b = secondSide; | ||
const c = thirdSide; | ||
const cosB = (((a * a) + (c * c) - (b * b)) / (2 * a * c)); | ||
const sinB = Math.sqrt(1 - cosB * cosB); | ||
return `The value of TanB is: ${sinB / cosB}`; | ||
} | ||
|
||
function calculateTanC(firstSide, secondSide, thirdSide) { | ||
const a = firstSide; | ||
const b = secondSide; | ||
const c = thirdSide; | ||
const cosC = (((a * a) + (b * b) - (c * c)) / (2 * a * b)); | ||
const sinC = Math.sqrt(1 - cosC * cosC); | ||
return `The value of TanC is: ${sinC / cosC}`; | ||
} |
Oops, something went wrong.