-
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.
- Loading branch information
1 parent
0aab856
commit 07e58cd
Showing
5 changed files
with
112 additions
and
0 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
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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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`; | ||
} |
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,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; | ||
} | ||
|
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