Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Web T 001

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

TUSHTEE SINGH

2100290120176

ASSIGNMENT 01
WEB TECHNOLOGY

1. Create a web page which will have one table and 2 paragraphs. Create
different styles for the table cells and paragraph. Maintain a separate style
sheet file for table whereas the styles for paragraph should be maintained
in the same file.
HTML CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Styled Table and Paragraphs</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Styled Table and Paragraphs</h1>

<!-- First paragraph with class 'paragraph1' -->


<p class="paragraph1"><b>HTML (Hypertext Markup Language)</b> is the standard language used
to create the structure and content of web pages. It uses tags to define elements such as headings,
paragraphs, links, images, and forms. HTML documents are interpreted by web browsers to display
content visually.</p>

<!-- Table with class 'styled-table' -->


<table class="styled-table">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</tbody>
</table>

<!-- Second paragraph with class 'paragraph2' -->


<p class="paragraph2"><p>CSS (Cascading Style Sheets) </p> It is a style sheet language used to
control the presentation and layout of HTML elements. It allows developers to customize the
appearance of web pages by defining styles such as colors, fonts, margins, and padding. CSS separates
the content from its presentation, enabling consistent design across multiple pages or websites.
</p>
</body>
</html>

CSS CODE:
/* Styles for the table */
.styled-table {
width: 100%;
border-collapse: collapse;
border: 2px solid #ddd;
}
.styled-table th, .styled-table td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
.styled-table th {
background-color: #f2f2f2;
}
/* Styles for paragraphs */
.paragraph1 {
color: blue;
font-size: 18px;
font-weight: bold;
}
.paragraph2 {
color: green;
font-size: 16px;
font-style: italic;
}
2. Create the following HTML page. Use HTML code to print the symbols.

HTML CODE:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Special Symbols</title>
</head>
<body>
<p>quotation mark: &quot;</p>
<p>amperand sign: &amp;</p>
<p>less than sign: &lt;</p>
<p>greater than sign: &gt;</p>
<p>copyright symbol: &copy;</p>
<p>registered symbol: &reg;</p>
<p>a blank space (non-breaking one space): &nbsp;</p>
</body>
</html>
3. Create a web page to print the following table:

HTML CODE:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Course-wise Subjects</title>
<style>
table {
width: 100%;
border-collapse: collapse;
background-color: rgb(55, 194, 222);
}
th, td {
border: 1px solid #200ac7;
padding: 8px;
text-align: left;
}
</style>
</head>
<body>
<h2>Course-wise Subjects</h2>
<table>
<thead>
<tr>
<th>Sr. No.</th>
<th>Course</th>
<th>Subjects</th>
<th>Marks
<table>
<tr>
<td>Internal</td>
<td>External</td>
</tr>
</table>
</th>
<th>Category
<table>
<tr>
<td>Internal</td>
<td>External</td>
</tr>
</table>
</th>
<th>Practical/Theory</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="4">1</td>
<td rowspan="4">MBA</td>
<td>Management Accounting</td>
<td>
<table>
<tr>
<td>30</td>
<td>70</td>
</tr>
</table>
</td>
<td>
<table>

<tr>
<td>-</td>

<td>✔</td>
</tr>
</table>
</td>
<td>Theory</td>
</tr>
<tr>
<td>Information Technology</td>
<td>
<table>
<tr>
<td>30</td>
<td>70</td>
</tr>
</table>
</td>
<td>
<table>

<tr>
<td>-</td>

<td>✔</td>
</tr>
</table>
</td>
<td>T and P</td>
</tr>
<tr>
<td>Basics of Marketing</td>
<td>
<table>

<tr>
<td>30</td>
<td>70</td>
</tr>
</table>
</td>
<td>
<table>

<tr>
<td>-</td>

<td>✔</td>
</tr>
</table>
</td>
<td>Theory</td>
</tr>
<tr>
<td>E-commerce</td>
<td>
<table>
<tr>
<td>50</td>
<td>-</td>
</tr>
</table>
</td>
<td>
<table>

<tr>

<td>✔</td>
<td>-</td>
</tr>
</table>
</td>
<td>Theory</td>
</tr>
<tr>
<td rowspan="6">2</td>
<td rowspan="6">MCM</td>
<td>Visual Basic</td>
<td>
<table>
<tr>
<td>30</td>
<td>70</td>
</tr>
</table>
</td>
<td>
<table>

<tr>
<td>-</td>

<td>✔</td>
</tr>
</table>
</td>
<td>T and P</td>
</tr>

<tr>
<td>Internet Technology</td>
<td>
<table>

<tr>
<td>30</td>
<td>70</td>
</tr>
</table>
</td>
<td>
<table>

<tr>
<td>-</td>

<td>✔</td>
</tr>
</table>
</td>
<td>T and P</td>
</tr>
<tr>
<td>Network Technology</td>
<td>
<table>

<tr>
<td>30</td>
<td>70</td>
</tr>
</table>
</td>
<td>
<table>

<tr>
<td>-</td>

<td>✔</td>
</tr>
</table>
</td>
<td>Theory</td>
</tr>
<tr>
<td>VB. Net</td>
<td>
<table>

<tr>
<td>30</td>
<td>70</td>
</tr>
</table>
</td>
<td>
<table>

<tr>
<td>-</td>

<td>✔</td>
</tr>
</table>
</td>
<td>T and P</td>
</tr>
<tr>
<td>Linux</td>
<td>
<table>

<tr>
<td>30</td>
<td>70</td>
</tr>
</table>
</td>
<td>
<table
<tr>
<td>-</td>

<td>✔</td>
</tr>
</table>
</td>
<td>T and P</td>
</tr>
<tr>
<td>ISA</td>
<td>
<table>
<tr>
<td>50</td>
<td>-</td>
</tr>
</table>
</td>
<td>
<table>
<tr>

<td>✔</td>
<td>-</td>
</tr>
</table>
</td>
<td>Theory</td>
</tr>
<tr>
</tbody>
</table>
</body>
</html>
4. Write a Java program to create a method that takes an integer as a parameter and
throws an exception if the number is odd.

CODE:

public class OddNumberException extends Exception {


public OddNumberException(String message) {
super(message);
}
}

public class Main {


public static void checkEven(int number) throws OddNumberException {
if (number % 2 != 0) {
throw new OddNumberException("Odd number detected!");
}
}

public static void main(String[] args) {


try {
checkEven(3); // Example usage
} catch (OddNumberException e) {
System.out.println(e.getMessage());
}
}
}

5. Write a Java program to create a method that takes a string as input and throws
an exception if the string does not contain vowels.
CODE:
public class NoVowelsException extends Exception {
public NoVowelsException(String message) {
super(message);
}
}

public class Main {


public static void checkVowels(String str) throws NoVowelsException {
if (!str.matches(".*[aeiouAEIOU].*")) {
throw new NoVowelsException("String does not contain any vowels!");
}
}

public static void main(String[] args) {


try {
checkVowels("xyz"); // Example usage
} catch (NoVowelsException e) {
System.out.println(e.getMessage());
}
}
}

6. Write a Java program that reads a list of integers from the user and throws an exception
if any numbers are duplicates.
CODE:
import java.util.*;

public class DuplicateNumberException extends Exception {


public DuplicateNumberException(String message) {
super(message);
}
}

public class Main {


public static void checkDuplicates(List<Integer> numbers) throws DuplicateNumberException {
Set<Integer> set = new HashSet<>();
for (int num : numbers) {
if (!set.add(num)) {
throw new DuplicateNumberException("Duplicate number detected: " + num);
}
}
}

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);
List<Integer> numbers = new ArrayList<>();
System.out.println("Enter numbers (type 'done' when finished):");
while (scanner.hasNextInt()) {
numbers.add(scanner.nextInt());
}
try {
checkDuplicates(numbers);
} catch (DuplicateNumberException e) {
System.out.println(e.getMessage());
}
}
}

7. Write a Java program to create a class called Vehicle with a method called drive(). Create
a subclass called Car that overrides the drive() method to print "Repairing a car".

CODE:
class Vehicle {
public void drive() {
System.out.println("Driving vehicle");
}
}

class Car extends Vehicle {


@Override
public void drive() {
System.out.println("Repairing a car");
}
}

public class Main {


public static void main(String[] args) {
Vehicle vehicle = new Vehicle();
vehicle.drive(); // Output: Driving vehicle

Car car = new Car();


car.drive(); // Output: Repairing a car
}
}

8. Write a Java program to create a class called Shape with a method called
getArea(). Create a subclass called Rectangle that overrides the getArea() method
to calculate the area of a rectangle.
CODE:
class Shape {
public double getArea() {
return 0.0;
}
}

class Rectangle extends Shape {


private double length;
private double width;

public Rectangle(double length, double width) {


this.length = length;
this.width = width;
}
@Override
public double getArea() {
return length * width;
}
}

public class Main {


public static void main(String[] args) {
Rectangle rectangle = new Rectangle(5, 10);
System.out.println("Area of rectangle: " + rectangle.getArea()); // Output: 50.0
}
}

9. What are the basic rules while writing XML?

XML is case-sensitive.
Every XML document must have a root element.
XML elements must be properly nested.
Attribute values must be quoted.
Comments are enclosed in <!-- -->.
XML tags cannot contain spaces.
Special characters like <, >, &, ', and " must be escaped using entities (&lt;, &gt;, &amp;,
&apos;, &quot;).

You might also like