Skip to content

Commit

Permalink
added recoil energy cal
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishakulkarni06 committed Dec 8, 2024
1 parent 0aab856 commit 07e58cd
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Calculators/Recoil-energy-calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h2>Recoil Energy calculator</h2>
<div class="inp">
<label>Enter mass of bullet (in kg) : </label>
<input placeholder="Enter mass of bullet" id="massBullet">
</div>
<div class="inp">
<label>Enter velocity of bullet (in meter / sec) : </label>
<input placeholder="Enter velocity of bullet" id="velBullet">
</div>
<div class="inp">
<label>Enter mass of gun (in kg) : </label>
<input placeholder="Enter mass of bullet" id="massGun">
</div>
<button onclick="calculateRecoilEnergy()">Calculate</button>
<div class="result" id="result"></div>
<script src="script.js"></script>
</div>
</body>
</html>
Binary file added Calculators/Recoil-energy-calculator/recoil.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions Calculators/Recoil-energy-calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let massBullet = document.getElementById('massBullet');
let velBullet = document.getElementById('velBullet');
let massGun = document.getElementById('massGun');
let result = document.getElementById('result');

function calculateRecoilEnergy(){
let mBullet = parseFloat(massBullet.value);
let vBullet = parseFloat(velBullet.value);
let mGun = parseFloat(massGun.value);

if (isNaN(mBullet) || isNaN(vBullet) || isNaN(mGun)) {
result.innerHTML = "Please enter valid numerical values";
return;
}

let E = (mBullet * (vBullet*vBullet) ) / (2 * mGun) ;
result.innerHTML = `Recoil energy is : ${E.toFixed(2)} Joules`;
}
49 changes: 49 additions & 0 deletions Calculators/Recoil-energy-calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
body{
background-image: url('./recoil.jpg');
background-size:cover;
background-repeat: no-repeat;
}

.container{
border: 3px solid white;
color: black;
width: 40%;
margin-top:10%;
margin-left: 30%;
height: 90%;
background-color: gray;
padding: 2%;
}

.container h2{
font-weight: bold;
}

.inp{
margin-bottom: 3%;
}

input{
height: 20%;
width: 40%;
}

button{
margin-bottom: 2%;
height: 2rem;
border-radius: 5%;
cursor: pointer;
border: none;
/* background-color: gray; */
}

button:hover{
background-color: rgba(244, 235, 235, 0.4);
}

.result{
color: red;
font-size: 1.5rem;
font-weight: bold;
}

16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4564,6 +4564,22 @@ <h3>This tool enables users to input ingredients and quantities to calculate the
</div>
</div>
</div>

<div class="box">
<div class="content">
<h2>Recoil Energy Calculator</h2>
<h3>This tool enables users to calculate recoil energy</h3>
<div class="card-footer">
<a href="./Calculators/Recoil-energy-calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Recipe-Cost-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>

<div class="box">
<div class="content">
<h2>Rectangular Polar Calculator</h2>
Expand Down

0 comments on commit 07e58cd

Please sign in to comment.