You are on page 1of 18

1. Write a html code to create your curriculum vitae.

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Your_Name - Curriculum Vitae</title>
</head>

<body>

<header>
<h1>Your_Name</h1>
<p>Email | Mobile</p> <p>Address | <a
href="https://www.linkedin.com/in/ ">LinkedIn</a> </p>
</header>

<section class="section"> <h2>Education</h2>


<div class="sub-section">
<h3>Dronacharya Group Of Institutions, B.Tech</h3>
<p>October 2021 – present</p>
</div>

<section class="section">
<h2>Languages</h2>
<p>English, Hindi</p>
</section>

<section class="section">
<h2>Skills</h2>
<pre>C++ Programming
Python Programming
C Programming
Front End Development
Data Structures and Algorithm</pre>
</section>

<section class="section">
<h2>Interests</h2>
<p>Hackathons and Coding Competition, Quizzes and Challenges, Fitness, Sketching,
Travelling</p>
</section>

<section class="section">
<h2>Certificates</h2>
<pre>C++ Programming,
Data Structure and Algorithm,
1|Page
Front-End Development
Python Programming</pre>
</section>

<section class="section">
</section>

</body>

</html>

2|Page
2. Create student registration form for an Institute using HTML.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Student Registration Form</title>
<style> body
{
font-family: Arial, sans-serif;
margin: 20px;
} label {
display: block;
margin-bottom: 5px;
}

textarea { width:
100%; padding: 8px;
margin-bottom: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}

input[type="submit"] {
padding: 10px 20px;
background-color: #007bff;
color: white; border:
none; border-radius:
5px; cursor: pointer;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
</style>
</head>
<body>

<h1>Student Registration Form</h1>

<form action="#" method="post">


<label for="fullname">Full Name:</label>
<input type="text" id="fullname" name="fullname" required>

<label for="email">Email:</label>
<input type="email" id="email" name="email" required>

<label for="phone">Phone Number:</label>


<input type="text" id="phone" name="phone" required>
3|Page
<label>Gender:</label>
<label for="male"><input type="radio" id="male" name="gender" value="Male" required>
Male</label>
<label for="female"><input type="radio" id="female" name="gender" value="Female" required>
Female</label>
<label for="other"><input type="radio" id="other" name="gender" value="Other" required>
Other</label>

<label for="course">Select Course:</label>


<select id="course" name="course" required>
<option value="">-- Select Course --</option>
<option value="Computer Science">Computer Science</option>
<option value="Engineering">Engineering</option>
<option value="Mathematics">Mathematics</option>
</select>
<label for="address">Address:</label>
<textarea id="address" name="address" required></textarea>
<input type="submit" value="Submit">
</form>

</body>
</html>

4|Page
3. Write a program in java to sort the given String array
alphabetically. name [ ] = {“Madras”, ”Delhi”,
”Ahmedabad”, ”Calcutta”,
”Bombay”};
import java.util.Arrays;

public class SortStringArrya


{
public static void main(String[] args)
{
String[] name = {"Madras", "Delhi", "Ahmedabad", "Calcutta", "Bombay"};

// Sorting the array alphabetically


Arrays.sort(name);

// Displaying the sorted array


System.out.println("Sorted Array:"); for
(String city : name)
System.out.println(city);
}
}

OUTPUT :-
Sorted Array:
Ahmedabad
Bombay
Calcutta
Delhi
Madras

5|Page
4. Write a Program in java to create a package Mops that consists of
mathematical operations like addition, subtraction, division,
modulus and multiplication as methods of class MathOps and use it
in another java file.
MathOps.java (inside the Mops package):

package Mops;

public class MathOps


{
public int addition(int a, int b) { return
a + b;
}

public int subtraction(int a, int b) { return


a - b;
}

public int division(int a, int b) {


if (b != 0) { return
a / b;
} else {
throw new ArithmeticException("Cannot divide by zero!");
}
}

public int modulus(int a, int b) {


if (b != 0) { return
a % b;
} else {
throw new ArithmeticException("Cannot find modulus with zero!");
}
}

public int multiplication(int a, int b) { return


a * b;
}
}

MainProgram.java (another Java file where you use the MathOps class):

import Mops.MathOps;

public class MainProgram {


6|Page
public static void main(String[] args) {
MathOps math = new MathOps();

// Using methods from MathOps class int


resultAddition = math.addition(5, 3); int
resultSubtraction = math.subtraction(10, 4); int
resultDivision = math.division(15, 3); int
resultModulus = math.modulus(17, 4);
int resultMultiplication = math.multiplication(6, 7);

// Displaying results
System.out.println("Addition: " + resultAddition);
System.out.println("Subtraction: " + resultSubtraction);
System.out.println("Division: " + resultDivision);
System.out.println("Modulus: " + resultModulus);
System.out.println("Multiplication: " + resultMultiplication);
}
}

7|Page
5. Write a program using JavaScript to display browser information.
<!DOCTYPE html>
<html>
<head>
<title>Browser Information</title>
<script>
function displayBrowserInfo()
{
document.getElementById("browserInfo").innerHTML =
"<strong>Browser Name:</strong> " + navigator.appName + "<br>" +
"<strong>Browser Version:</strong> " + navigator.appVersion + "<br>" +
"<strong>Platform:</strong> " + navigator.platform + "<br>" +
"<strong>User Agent:</strong> " + navigator.userAgent + "<br>" +
"<strong>Cookies Enabled:</strong> " + navigator.cookieEnabled + "<br>";
}
</script>
</head>
<body>
<h1>Browser Information</h1>
<button onclick="displayBrowserInfo()">Display Browser Info</button>
<div id="browserInfo"></div>
</body>
</html>

8|Page
6. Create a calculator using HTML, CSS and JavaScript.

<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
<style>
#calculator { width:
300px;
margin: 0 auto;
}

.display {
width: 100%; height:
50px; text-align: right;
font-size: 20px;
}

.buttons { display: flex;


flex-direction: column;
justify-content: space-between;
}

.number, .operator, .equal {


width: 50px; height:
50px;
font-size: 20px;
}
</style>
</head>
<body>
<div id="calculator">
<input type="text" class="display" />
<div class="buttons">
<button type="button" class="number">7</button>
<button type="button" class="number">8</button>
<button type="button" class="number">9</button>
<button type="button" class="operator">/</button>
<button type="button" class="number">4</button>
<button type="button" class="number">5</button>
<button type="button" class="number">6</button>
<button type="button" class="operator">*</button>
<button type="button" class="number">1</button>
<button type="button" class="number">2</button>
<button type="button" class="number">3</button>
9|Page
<button type="button" class="operator">-</button>
<button type="button" class="number">0</button>
<button type="button" class="number">.</button>
<button type="button" class="operator">+</button>
<button type="button" class="equal">=</button>
</div>
</div>

<script>
const display = document.querySelector('.display');
const buttons = document.querySelectorAll('.buttons button');

buttons.forEach(button => { button.addEventListener('click', ()


=> {
const value = button.textContent;

if (value === '=') {


const result = eval(display.textContent);
display.textContent = result;
} else {
display.textContent += value;
}
});
});
</script>
</body>
</html>

10 | P a g e
7. Write JavaScript to validate the following fields of the
Registration page.
1. First Name and Last Name should contain alphabets and must
not be empty
2. Password must not be less than 6 characters length.
3. E-mail id (should not contain any invalid and must follow the
standard pattern
4. Example name@domain.com)
5. Mobile Number (Phone number should contain 10 digits only).
6. Address should not be Empty.
<!DOCTYPE html>
<html>
<head>
<title>Registration Page</title>
<script>
function validateRegistration() {
var firstName = document.getElementById('firstName').value; var
lastName = document.getElementById('lastName').value; var
password = document.getElementById('password').value; var
email = document.getElementById('email').value; var mobile =
document.getElementById('mobile').value; var address =
document.getElementById('address').value;

var nameRegex = /^[a-zA-Z]+$/;


var emailRegex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; var
mobileRegex = /^\d{10}$/;

if (!nameRegex.test(firstName) || firstName === '') {


alert('First Name should contain alphabets and must not be empty.'); return
false;
}

if (!nameRegex.test(lastName) || lastName === '') {


alert('Last Name should contain alphabets and must not be empty.'); return
false;
}

if (password.length < 6) {
alert('Password must be at least 6 characters long.'); return
false;
}

11 | P a g e
if (!emailRegex.test(email)) {
alert('Invalid Email format. Please enter a valid email.'); return
false;
}

if (!mobileRegex.test(mobile)) {
alert('Mobile number should contain 10 digits only.'); return
false;
}

if (address === '') { alert('Address


should not be empty.'); return false;
}

return true; // If all validations pass


}
</script>
</head>
<body>
<h1>Registration Page</h1>
<form onsubmit="return validateRegistration()">
First Name: <input type="text" id="firstName"><br><br>
Last Name: <input type="text" id="lastName"><br><br>
Password: <input type="password" id="password"><br><br>
Email: <input type="text" id="email"><br><br>
Mobile: <input type="text" id="mobile"><br><br>
Address: <textarea id="address"></textarea><br><br>
<input type="submit" value="Register">
</form>
</body> </html>

12 | P a g e
8. Writing program in XML for creation of DTD, which specifies set
of rules.
<!DOCTYPE bookstore [
<!ELEMENT bookstore (book+)>
<!ELEMENT book (title, author, genre, price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT genre (#PCDATA)>
<!ELEMENT price (#PCDATA)>
]>
<bookstore>
<book>
<title>Sample Book Title</title>
<author>John Doe</author>
<genre>Fiction</genre>
<price>19.99</price>
</book>
<book>
<title>Another Book Title</title>
<author>Jane Smith</author>
<genre>Non-fiction</genre>
<price>24.95</price>
</book>
</bookstore>

13 | P a g e
9. Write a java program/servlet/JSP to connect database and
create a table customer_info and insert the following records in it.
CustomI Customer_Nam Last_Nam Ag Countr
D e e e y
C101 Shankaran Pillai 29 India
C102 John Doe 25 US
C103 David Robinson 28 UK

import java.sql.*;

public class CustomerInfo {


static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; // JDBC driver for your
database

static final String DB_URL = "jdbc:mysql://localhost/your_database"; //


Database URL

static final String USER = "Deepak";


static final String PASS = "Baghel";
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
try {
// Register JDBC driver
Class.forName(JDBC_DRIVER);
// Open a connection
System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL, USER, PASS);
// Execute a query to create the table
System.out.println("Creating table customer_info..."); stmt = conn.createStatement();
String sql = "CREATE TABLE customer_info (" +
"CustomID VARCHAR(10), " +
"Customer_Name VARCHAR(50), " +
"Last_Name VARCHAR(50), " +
"Age INT, " +
"Country VARCHAR(50))";
stmt.executeUpdate(sql);
System.out.println("Table created successfully.");
// Insert records into the table

14 | P a g e
System.out.println("Inserting records into the table...");
sql = "INSERT INTO customer_info VALUES " +

"('C101', 'Shankaran', 'Pillai', 29, 'India'), " +

"('C102', 'John', 'Doe', 25, 'US'), " + "('C103', 'David', 'Robinson', 28, 'UK')";
stmt.executeUpdate(sql);

System.out.println("Records inserted successfully.");


}
catch (SQLException se)
{se.printStackTrace(); }
catch (Exception e)
{ e.printStackTrace(); }
finally { try { if (stmt != null) stmt.close();}
catch (SQLException se2) {
} try {
if (conn != null) conn.close(); } catch (SQLException se) {se.printStackTrace();
}
}
}
}

15 | P a g e
10. Write a java program/servlet/JSP to connect database and
extract data from the table customer_info (ref: Practical 9) and
display them.

import java.sql.*;

public class DisplayCustomerInfo {

static final String JDBC_DRIVER = " com.mysql.jdbc.Driver "; // JDBC driver for your
database
static final String DB_URL = "jdbc:mysql://localhost/your_database"; // Database
URL

static final String USER = "Deepak";


static final String PASS = "Baghel";

public static void main(String[] args) {


Connection conn = null;
Statement stmt = null;

try {
// Register JDBC driver
Class.forName(JDBC_DRIVER);

// Open a connection
System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL, USER, PASS);

// Execute a query to retrieve data


System.out.println("Fetching records from customer_info table..."); stmt =
conn.createStatement();
String sql = "SELECT * FROM customer_info";
ResultSet rs = stmt.executeQuery(sql);

// Displaying data
while (rs.next()) {
String customID = rs.getString("CustomID");
String customerName = rs.getString("Customer_Name");
String lastName = rs.getString("Last_Name"); int
age = rs.getInt("Age");
String country = rs.getString("Country");

// Print retrieved data

16 | P a g e
System.out.println("CustomID: " + customID);
System.out.println("Customer Name: " + customerName);
System.out.println("Last Name: " + lastName);
System.out.println("Age: " + age);
System.out.println("Country: " + country);
System.out.println("-----------------------");
}
rs.close();

} catch (SQLException se) {


se.printStackTrace(); } catch
(Exception e) {
e.printStackTrace(); } finally {
try { if (stmt != null)
stmt.close();
} catch (SQLException se2) {
} try { if (conn != null)
conn.close(); } catch
(SQLException se) {
se.printStackTrace();
}
}
}
}

17 | P a g e

You might also like