Now you don’t have any excuse.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Math Equation Solver</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f7f6;
margin: 0;
padding: 40px;
color: #333;
}
h1 {
text-align: center;
color: #2c3e50;
margin-bottom: 30px;
}
#game-container {
max-width: 900px;
margin: 0 auto;
background: #fff;
padding: 20px 30px;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.equation-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 15px;
padding: 15px 0;
border-bottom: 1px solid #eee;
}
.equation-row:last-child {
border-bottom: none;
}
.equation-text {
font-family: "Courier New", Courier, monospace;
font-size: 1.15em;
font-weight: bold;
flex: 1;
min-width: 320px;
color: #2980b9;
}
.input-box {
width: 80px;
padding: 8px;
font-size: 1em;
border: 1px solid #ccc;
border-radius: 5px;
text-align: center;
}
.btn {
padding: 8px 15px;
font-size: 1em;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
transition: background 0.3s;
}
.btn-start {
background-color: #f39c12;
color: #fff;
}
.btn-start:hover { background-color: #e67e22; }
.btn-check {
background-color: #27ae60;
color: #fff;
}
.btn-check:hover { background-color: #219150; }
.btn-check:disabled, .btn-start:disabled {
background-color: #95a5a6;
cursor: not-allowed;
}
.btn-refresh {
background-color: #3498db;
color: #fff;
display: none;
}
.btn-refresh:hover { background-color: #2980b9; }
.timer {
font-family: monospace;
font-size: 1.1em;
color: #e74c3c;
min-width: 65px;
}
.feedback {
font-weight: bold;
min-width: 170px;
}
.correct { color: #27ae60; }
.incorrect { color: #c0392b; }
#score-container {
max-width: 900px;
margin: 20px auto 0;
background: #e8f8f5;
padding: 15px 30px;
border-radius: 10px;
border: 2px solid #1abc9c;
text-align: center;
font-size: 1.5em;
font-weight: bold;
color: #16a085;
box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
</style>
</head>
<body>
<h1>Solve the Equations</h1>
<div id="game-container"></div>
<div id="score-container">
Total Score: <span id="total-score">0</span>
</div>
<script>
const activeEquations = new Set();
const TOTAL_EQUATIONS = 6;
let globalScore = 0;
function generateEquationLogic() {
// Pattern 1/x for percentage
const x = Math.floor(Math.random() * 24) + 2;
let P_str = (100 / x).toFixed(2);
if (P_str.endsWith('.00')) {
P_str = P_str.slice(0, -3);
}
// Generate 11-99 for multipliers and divisor
let A = Math.floor(Math.random() * 89) + 11;
let B = Math.floor(Math.random() * 89) + 11;
let D = Math.floor(Math.random() * 89) + 11;
let E = Math.floor(Math.random() * 89) + 11;
// Guarantee an integer result for the percentage/division chunk
let C_mult = Math.floor(Math.random() * 5) + 1;
let C = x * D * C_mult;
// Ensure the final result is positive
while ((A * B) <= (C_mult * E)) {
A = Math.floor(Math.random() * 89) + 11;
B = Math.floor(Math.random() * 89) + 11;
}
// Calculate final integer answer
const answer = (A * B) - (C_mult * E);
const text = `${A} * ${B} - ${P_str}% ${C} / ${D} * ${E}`;
return { text, answer };
}
function getUniqueEquation() {
let eq;
do {
eq = generateEquationLogic();
} while (activeEquations.has(eq.text));
return eq;
}
function createRow(container) {
const row = document.createElement('div');
row.className = 'equation-row';
let eqData = getUniqueEquation();
activeEquations.add(eqData.text);
// Create UI elements
const eqText = document.createElement('div');
eqText.className = 'equation-text';
eqText.textContent = eqData.text;
const startBtn = document.createElement('button');
startBtn.className = 'btn btn-start';
startBtn.textContent = 'Start Timer';
const input = document.createElement('input');
input.type = 'number';
input.className = 'input-box';
input.placeholder = '?';
input.disabled = true; // Disabled until start is clicked
const checkBtn = document.createElement('button');
checkBtn.className = 'btn btn-check';
checkBtn.textContent = 'Check';
checkBtn.disabled = true; // Disabled until start is clicked
const refreshBtn = document.createElement('button');
refreshBtn.className = 'btn btn-refresh';
refreshBtn.textContent = 'Refresh';
const timerDiv = document.createElement('div');
timerDiv.className = 'timer';
timerDiv.textContent = '00:00';
const feedbackDiv = document.createElement('div');
feedbackDiv.className = 'feedback';
let seconds = 0;
let timerInterval;
// --- Start Timer Logic ---
startBtn.addEventListener('click', () => {
input.disabled = false;
checkBtn.disabled = false;
startBtn.style.display = 'none';
input.focus();
timerInterval = setInterval(() => {
seconds++;
const mins = String(Math.floor(seconds / 60)).padStart(2, '0');
const secs = String(seconds % 60).padStart(2, '0');
timerDiv.textContent = `${mins}:${secs}`;
}, 1000);
});
// --- Check Button Logic ---
checkBtn.addEventListener('click', () => {
if (input.value === '') return;
clearInterval(timerInterval);
const userAnswer = parseInt(input.value, 10);
if (userAnswer === eqData.answer) {
const pointsEarned = Math.max(10, 100 - seconds);
globalScore += pointsEarned;
document.getElementById('total-score').textContent = globalScore;
feedbackDiv.textContent = `You got right (+${pointsEarned})`;
feedbackDiv.className = 'feedback correct';
} else {
feedbackDiv.textContent = `Correct answer is ${eqData.answer}`;
feedbackDiv.className = 'feedback incorrect';
}
input.disabled = true;
checkBtn.disabled = true;
refreshBtn.style.display = 'inline-block';
});
// --- Refresh Button Logic ---
refreshBtn.addEventListener('click', () => {
activeEquations.delete(eqData.text);
eqData = getUniqueEquation();
activeEquations.add(eqData.text);
eqText.textContent = eqData.text;
input.value = '';
input.disabled = true;
checkBtn.disabled = true;
feedbackDiv.textContent = '';
refreshBtn.style.display = 'none';
startBtn.style.display = 'inline-block';
seconds = 0;
timerDiv.textContent = '00:00';
clearInterval(timerInterval);
});
// Append everything to the row
row.appendChild(eqText);
row.appendChild(startBtn);
row.appendChild(input);
row.appendChild(checkBtn);
row.appendChild(refreshBtn);
row.appendChild(timerDiv);
row.appendChild(feedbackDiv);
container.appendChild(row);
}
// Initialize equations when the page loads
document.addEventListener("DOMContentLoaded", function() {
const gameContainer = document.getElementById('game-container');
if (gameContainer) {
for (let i = 0; i < TOTAL_EQUATIONS; i++) {
createRow(gameContainer);
}
}
});
</script>
</body>
</html>

← Back

Thank you for your response. ✨