Area of a Rectangle Worksheet

Rectangular Array Area Worksheet

1 square unit

For each question, calculate the area of the blue rectangular array.

`; printWindow.document.write(printContent); printWindow.document.close(); // Wait for content to load before printing printWindow.onload = function() { printWindow.print(); printWindow.onafterprint = function() { printWindow.close(); }; }; }); function createGrid(rows, cols) { const grid = document.createElement('div'); grid.className = 'grid'; grid.style.gridTemplateColumns = `repeat(${cols}, 30px)`; for (let i = 0; i < rows * cols; i++) { const cell = document.createElement('div'); cell.className = 'cell'; grid.appendChild(cell); } return grid; } function createRectangle(width, height) { const container = document.createElement('div'); container.className = 'rectangle'; const shape = document.createElement('div'); shape.className = 'rectangle-shape'; shape.style.width = `${width * 30}px`; shape.style.height = `${height * 30}px`; const widthLabel = document.createElement('div'); widthLabel.className = 'dimension width'; widthLabel.textContent = `${width} units`; const heightLabel = document.createElement('div'); heightLabel.className = 'dimension height'; heightLabel.textContent = `${height} units`; container.appendChild(shape); container.appendChild(widthLabel); container.appendChild(heightLabel); return container; } function generateUniqueProblems() { const problems = new Set(); while (problems.size < 10) { const rows = Math.floor(Math.random() * 5) + 2; const cols = Math.floor(Math.random() * 5) + 2; problems.add(`${rows},${cols}`); } return Array.from(problems).map(p => { const [rows, cols] = p.split(',').map(Number); return { rows, cols, area: rows * cols }; }); } function createQuestion(problem, index) { const questionDiv = document.createElement('div'); questionDiv.className = 'question'; questionDiv.innerHTML = `

Question ${index + 1}

`; if (currentOption === "1") { questionDiv.appendChild(createGrid(problem.rows, problem.cols)); const answerSpace = document.createElement('div'); answerSpace.innerHTML = `

Total number of squares:

Area = ${problem.rows} × =

`; questionDiv.appendChild(answerSpace); } else { questionDiv.appendChild(createRectangle(problem.cols, problem.rows)); const answerSpace = document.createElement('div'); answerSpace.innerHTML = `

Area = × =

`; questionDiv.appendChild(answerSpace); } return questionDiv; } function displayAnswers() { answersSection.innerHTML = '

Answers

'; questionData.forEach((q, index) => { answersSection.innerHTML += `

Question ${index + 1}:

${currentOption === "1" ? `

Total number of squares: ${q.area}

` : '' }

Area = ${q.rows} × ${q.cols} = ${q.area} square units

`; }); answersSection.classList.remove('hidden'); } function generateWorksheet() { worksheet.innerHTML = ''; questionData = generateUniqueProblems(); answersSection.classList.add('hidden'); questionData.forEach((problem, index) => { worksheet.appendChild(createQuestion(problem, index)); }); } optionButtons.forEach(button => { button.addEventListener('click', () => { currentOption = button.dataset.option; optionButtons.forEach(btn => btn.classList.remove('active')); button.classList.add('active'); if (currentOption === "1") { option1Content.classList.remove('hidden'); option2Content.classList.add('hidden'); } else { option1Content.classList.add('hidden'); option2Content.classList.remove('hidden'); } generateWorksheet(); }); }); generateWorksheet(); generateNewButton.addEventListener('click', generateWorksheet); showAnswersButton.addEventListener('click', displayAnswers);

Your second block of text...