Kingks Exam Percentage Calculator
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Kingks Exam Percentage Calculator</title>
<style>
body {
font-family: ‘Roboto’, sans-serif;
margin: 0;
padding: 0;
animation: backgroundChange 10s infinite;
background: #f3f3f3;
}
@keyframes backgroundChange {
0% { background-color: #ffcccb; }
25% { background-color: #c8f7c5; }
50% { background-color: #c5d9ff; }
75% { background-color: #fff3c5; }
100% { background-color: #f5c7f7; }
}
h2 {
text-align: center;
font-size: 2em;
color: #333;
margin: 0;
padding-top: 20px;
text-shadow: 1px 1px 5px rgba(0,0,0,0.1);
}
.logos {
display: flex;
justify-content: space-between;
position: absolute;
top: 50px;
width: 100%;
padding: 0 20px;
box-sizing: border-box;
}
.logos img {
max-width: 120px;
height: auto;
border-radius: 8px;
}
.card {
background: rgba(255, 255, 255, 0.5);
padding: 20px;
margin: 0 auto;
width: 90%;
max-width: 600px;
border-radius: 8px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
margin-top: 80px;
}
.card-header {
font-size: 1.2em;
color: #333;
font-weight: bold;
margin-bottom: 10px;
}
table {
width: 100%;
margin-top: 20px;
border-collapse: collapse;
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #28a745;
color: white;
text-transform: uppercase;
}
input[type=”text”] {
width: 90%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 6px;
box-sizing: border-box;
transition: border-color 0.3s ease;
}
input[type=”text”]:hover, input[type=”text”]:focus {
border-color: #28a745;
}
input[type=”text”]:focus {
background-color: #e6f7e6;
}
.error {
color: red;
font-size: 1em;
text-align: center;
}
.result {
margin-top: 20px;
font-size: 1.2em;
color: #333;
text-align: center;
}
.footer {
text-align: center;
margin-top: 30px;
font-size: 1em;
color: #555;
}
.footer a {
color: #28a745;
text-decoration: none;
}
.footer a:hover {
text-decoration: underline;
}
.congrats {
font-size: 1.5em;
color: #28a745;
text-align: center;
margin-top: 20px;
}
@media (max-width: 768px) {
.logos {
flex-direction: column;
align-items: center;
padding: 0;
}
.logos img {
max-width: 100px;
margin: 10px 0;
}
.card {
width: 95%;
margin-top: 100px;
}
table td {
padding: 8px;
}
input[type=”text”] {
width: 80%;
}
}
@media (max-width: 480px) {
h2 {
font-size: 1.5em;
}
.card-header {
font-size: 1em;
}
.logos img {
max-width: 90px;
}
table td {
padding: 6px;
}
input[type=”text”] {
width: 75%;
}
}
</style>
</head>
<body>
<h2>Kingks Exam Percentage Calculator</h2>
<form id=”marksForm”>
<div class=”logos”>
<img src=”https://kingks.xyz/wp-content/uploads/2024/08/cropped-channels4_profile-174×174.jpg” alt=”Logo Left”>
<img src=”https://kingks.xyz/wp-content/uploads/2024/12/1000040775-removebg-preview7736206797455868450.png” alt=”Logo Right”>
</div>
<div class=”card”>
<div class=”card-header”>Enter Your Marks</div>
<table>
<tr>
<th>Subject</th>
<th>Marks (out of 80)</th>
</tr>
<tr>
<td>Computer Science</td>
<td><input type=”text” id=”computer” name=”computer” placeholder=”Enter marks” oninput=”validateLive()”></td>
</tr>
<tr>
<td>Science</td>
<td><input type=”text” id=”science” name=”science” placeholder=”Enter marks” oninput=”validateLive()”></td>
</tr>
<tr>
<td>Maths</td>
<td><input type=”text” id=”maths” name=”maths” placeholder=”Enter marks” oninput=”validateLive()”></td>
</tr>
<tr>
<td>Social Studies</td>
<td><input type=”text” id=”sst” name=”sst” placeholder=”Enter marks” oninput=”validateLive()”></td>
</tr>
<tr>
<td>Hindi</td>
<td><input type=”text” id=”hindi” name=”hindi” placeholder=”Enter marks” oninput=”validateLive()”></td>
</tr>
<tr>
<td>English</td>
<td><input type=”text” id=”english” name=”english” placeholder=”Enter marks” oninput=”validateLive()”></td>
</tr>
<tr>
<td style=”text-align: center; margin-top: 10px;”>
<strong>Total Marks (Max 480):</strong> <span id=”liveTotal”>0.00</span> / 480
</td>
</tr>
</table>
</div>
<div id=”error” class=”error”></div>
<div id=”result” class=”result”></div>
<div class=”congrats” id=”congratsMessage”></div>
</form>
<div class=”footer”>
Made by <strong>Krishna Sengar</strong>, Class 9 – <a href=”https://kingks.xyz”>Visit my website</a>
</div>
<script>
function validateLive() {
const subjects = [“computer”, “science”, “maths”, “sst”, “hindi”, “english”];
const errorDiv = document.getElementById(‘error’);
const resultDiv = document.getElementById(‘result’);
const liveTotalDiv = document.getElementById(‘liveTotal’);
const congratsMessage = document.getElementById(‘congratsMessage’);
errorDiv.innerHTML = “”;
const marksPattern = /^(?:[0-7]?[0-9](?:\.\d{1,2})?|80(?:\.0{1,2})?)$/;
let totalMarks = 0;
let isValid = true;
subjects.forEach(subject => {
const input = document.getElementById(subject);
const value = input.value.trim();
if (!marksPattern.test(value) && value !== “”) {
isValid = false;
errorDiv.innerHTML += `<p>Invalid marks for ${subject.charAt(0).toUpperCase() + subject.slice(1)}. Enter a number between 0 and 80 (up to 2 decimal places).</p>`;
} else if (value !== “”) {
totalMarks += parseFloat(value);
}
});
liveTotalDiv.textContent = totalMarks.toFixed(2);
if (isValid) {
const percentage = (totalMarks / (subjects.length * 80)) * 100;
resultDiv.innerHTML = `<p><strong>Percentage:</strong> ${percentage.toFixed(2)}%</p>`;
congratsMessage.textContent = `Great job! Keep up the good work.`;
} else {
resultDiv.innerHTML = “”;
congratsMessage.textContent = “”;
}
}
</script>
</body>
</html>
I AM KINGKS