<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Punjab School 8th Result Percentage Calculator</title>
<style>
body {
font-family: sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f4f4f4;
margin: 0;
}
.calculator {
background-color: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
text-align: center;
}
h2 {
margin-bottom: 20px;
color: #333;
}
.input-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
color: #555;
font-weight: bold;
}
input[type="number"] {
width: calc(100% - 22px);
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
font-size: 16px;
}
button {
background-color: #007bff;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
.result {
margin-top: 20px;
font-size: 18px;
font-weight: bold;
color: #28a745;
}
</style>
</head>
<body>
<div class="calculator">
<h2>Punjab School 8th Result Percentage Calculator</h2>
<div class="input-group">
<label for="obtainedMarks">Marks Obtained (Out of 600):</label>
<input type="number" id="obtainedMarks" placeholder="Enter your obtained marks">
</div>
<button onclick="calculatePercentage()">Calculate Percentage</button>
<div class="result" id="percentageResult"></div>
</div>
<script>
function calculatePercentage() {
const obtainedMarksInput = document.getElementById("obtainedMarks");
const percentageResultDiv = document.getElementById("percentageResult");
const totalMarks = 600;
const obtainedMarks = parseFloat(obtainedMarksInput.value);
if (isNaN(obtainedMarks) || obtainedMarks < 0 || obtainedMarks > totalMarks) {
percentageResultDiv.textContent = "Please enter valid marks obtained (between 0 and 600).";
percentageResultDiv.style.color = "#dc3545"; // Error color
return;
}
const percentage = (obtainedMarks / totalMarks) * 100;
percentageResultDiv.textContent = "Your Percentage: " + percentage.toFixed(2) + "%";
percentageResultDiv.style.color = "#28a745"; // Success color
}
</script>
</body>
</html>