Web Programming - Assignment
Web Programming - Assignment
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
table {
width: 50%;
border-collapse: collapse;
th, td {
padding: 8px;
text-align: left;
th {
background-color: #f2f2f2;
</style>
</head>
<body>
<h2>Student Grades</h2>
<table>
<thead>
<tr>
<th>Student Name</th>
<th>Marks</th>
<th>Grade</th>
</tr>
</thead>
<tbody id="studentTableBody">
<!-- The table data will be inserted here by the JavaScript code -->
</tbody>
</table>
<script>
const students = [
];
function computeAverage(students) {
let sum = 0;
sum += students[i].marks;
function computeGrade(marks) {
return 'F';
return 'D';
return 'C';
return 'B';
} else {
return 'A';
nameCell.textContent = student.name;
marksCell.textContent = student.marks;
gradeCell.textContent = computeGrade(student.marks);
row.appendChild(nameCell);
row.appendChild(marksCell);
row.appendChild(gradeCell);
tableBody.appendChild(row);
document.body.appendChild(avgMarksSpan);
document.body.appendChild(avgGradeSpan);
</script>
</body>
</html>
Question 7
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CV Example</title>
<style>
table {
border-collapse: collapse;
width: 70%;
margin: 0 auto;
th, td {
padding: 10px;
th {
background-color: #f2f2f2;
h4 {
text-align: center;
margin: 10px 0;
</style>
</head>
<body>
<table>
<thead>
<tr>
</tr>
<tr>
<th>Contact Information</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>Email: [email protected]</p>
<p>Phone: 123-456-7890</p>
</td>
<td>
</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="2"><h2>Education</h2></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>University of XYZ</p>
</td>
<td>
</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="2"><h2>Experience</h2></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">
<h4>Software Engineer</h4>
<p>Company 123</p>
<ul>
</ul>
</td>
</tr>
<tr>
<td colspan="2">
<p>Company 456</p>
<ul>
</ul>
</td>
</tr>
</tbody>
</table>
</body>
</html>
Question 8
<?php
class Calculator {
private $result;
$this->result = 0;
$this->result += $number;
$this->result -= $number;
return $this->result;
$calculator->add(4);
$calculator->add(5);
$calculator->subtract(3);
$result = $calculator->getResult();
?>
Question 9
for($row=1;$row<=8;$row++)
echo "<tr>";
for($column=1;$column<=8;$column++)
$total=$row+$column;
if($total%2==0)
else
echo "</tr>";
?>
</table>
Question 10
<!DOCTYPE html>
<html>
<body>
<input type="submit">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$units = $_POST["units"];
$cost = 0;
} else {
}
echo "The cost of " . $units . " units is: " . $cost;
?>
</body>
</html>