The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

Class 12 - IT - Subject code 802 - Practicals Record

Discover the best professional documents and content resources in AnyFlip Document Base.
Search

Class 12 - IT - Subject code 802 - Practicals Record

Class 12 - IT - Subject code 802 - Practicals Record

PRACTICAL LAB MANUAL
SUBJECT CODE: 802
SUBJECT: IT
CLASS: XII

SUDHAKAR. R
DEPARTMENT OF CS
JAIN VIDYAASHRAM(CBSE)

SQL QUERIES

S.NO DATE TOPIC
1
2 Creation of a database using mysql command.
3
4 Deletion of a database using mysql command.
5
Creation of a table using mysql command.
6
7 Show the databases and tables created in mysql.
8
List out the field name along with its field type and
9 constraints for a table.

10 Set a default value for a field in a table.

INSERT VALUES INTO the table.

Display the details of a field in a Table based on a given
condition.

UPDATE the details of a field in a Table based on a given
condition.

AGGREGATE FUNCTIONS in mysql.

S.NO DATE JAVA PROGRAM
1 TOPIC
2 Print the string Hello World.
3
4 Display character A to Z using for loop.
5
6 Check if a given Number is Positive or Negative or Zero
7 using if..else statement.
8
9 Find the largest among three numbers using if..else
10 statement.

S.NO Check whether a number is even or odd using if...else
1 statement.
2
3 Generate Multiplication Table (number of iteration from 1
to 10) using for loop.

Find the Area of Rectangle by getting the input of length
and breadth from the user during run time.

Print the sum of first 10 natural numbers 1 to 10.

Generate FIBONACCI SERIES by getting the input of
number of terms in the series during run time.

Print the FACTORIAL of a given number.

OPERATING WEB BASED APPLICATION
DATE TOPIC

Case Study -1 Online Bill Calculator - Book Rail Ticket.

Case Study – 2 Online Quiz - Internet and Phone Safety
for School Children.

Case Study – 3 - Online Game – Hangman.

SQL

QUERIES

(10 MARKS)

1. Write down syntax and mysql program to create a database STUDENT and its
OUTPUT.
AIM
To write a MYSQL code to create a database STUDENT listing out its SYNTAX, and
its OUTPUT.
SYNTAX

PROGRAM
mysql> create database student;

OUTPUT

2. Write down syntax and mysql program to delete a database STUDENT and its
OUTPUT.
AIM
To write a MYSQL code to delete a database STUDENT listing out its SYNTAX, and
its OUTPUT.
SYNTAX

PROGRAM
mysql> drop database student;

OUTPUT

3. Write down a mysql program to create a table TEACHER with the following field
names given below and its OUTPUT.

• Teacher_ID,
• First_Name,
• Last_Name,
• Gender,
• Salary,
• Date_of_Birth,
• Dept_No

AIM
To write a mysql code to create a table TEACHER with the given field names

• Teacher_ID,
• First_Name,
• Last_Name,
• Gender,
• Salary,
• Date_of_Birth,
• Dept_No

and its OUTPUT.

PROGRAM

mysql> CREATE TABLE TEACHER
(
Teacher_ID INTEGER,
First_Name VARCHAR(20),
Last_Name VARCHAR(20),
Gender CHAR(1),
Salary DECIMAL(10,2),
Date_of_Birth DATE,
Dept_No INTEGER
);

OUTPUT

4. Write down mysql program to show the databases and tables created?
AIM
To write a mysql command to show the databases and tables and its output.
PROGRAM
mysql> show databases;
OUTPUT

PROGRAM
mysql> show tables;
OUTPUT

5. Write a mysql program to list out the field name Teacher_ID,
First_Name, Last_Name, Gender, Salary, Date_of_Birth, Dept_No
along with its field type and constraints for the table TEACHER in the database
STUDENT.

AIM
To write a mysql program to list out the field name Teacher_ID, First_Name,
Last_Name, Gender, Salary, Date_of_Birth, Dept_No
along with its field type and constraints for the table TEACHER in the database
STUDENT

PROGRAM
mysql > use student;
Database changed

mysql > desc teacher;

OUTPUT

6. Write down mysql program to set a default value for the field SALARY as
30000 to the table name TEACHER whose field names are listed below

• Teacher_ID,
• First_Name,
• Last_Name,
• Gender,
• Salary,
• Date_of_Birth,
• Dept_No

AIM

To write a mysql command to set a default value for the field SALARY as
30000 in table TEACHER.

PROGRAM

mysql > desc teacher;

mysql > ALTER TABLE TEACHER ALTER SALARY SET DEFAULT 30000;

OUTPUT

7. Write a mysql command to INSERT VALUES INTO table TEACHER in its field
Teacher_ID, First_Name, Last_Name, Gender, Salary, Date_of_Birth, Dept_No

AIM

To write a mysql command to INSERT VALUES INTO table TEACHER in its field
Teacher_ID, First_Name, Last_Name, Gender, Salary, Date_of_Birth, Dept_No

PROGRAM

mysql > INSERT INTO Teacher (Teacher_ID, First_Name, Last_Name,
Gender, Salary, Date_of_Birth, Dept_No) VALUES(101,"Shanaya", "Batra",
'F', 50000, '1984-08-11', 1);

OUTPUT

8. Write a mysql command to display the details of a Teacher whose
Teacher_ID=101.

The field names in Teacher table is listed below.

• Teacher_ID,
• First_Name,
• Last_Name,
• Gender,
• Salary,
• Date_of_Birth,
• Dept_No

AIM

To write a mysql command to display the details of Teacher_ID=101 in table
TEACHER with its field names listed below.

• Teacher_ID,
• First_Name,
• Last_Name,
• Gender,
• Salary,
• Date_of_Birth,
• Dept_No

PROGRAM

mysql > SELECT * FROM TEACHER WHERE Teacher_ID=101;

OUTPUT

9. Write a mysql command to UPDATE the details of Salary as 55000 in Teacher
table whose Teacher_ID=101.
The field names in Teacher table is listed below.
Teacher_ID, First_Name, Last_Name, Gender, Salary, Date_of_Birth, Dept_No
AIM
To write a mysql command to display the UPDATED details of Salary as 55000
for Teacher_ID=101 in table TEACHER with its field names listed below.
Teacher_ID, First_Name, Last_Name, Gender, Salary, Date_of_Birth, Dept_No
PROGRAM
mysql> UPDATE Teacher SET Salary=55000 WHERE Teacher_ID=101;

OUTPUT

10. Write a mysql command to find the following using AGGREGATE FUNCTIONS
in Table Teacher. The field names in Teacher table is listed below.
Teacher_ID, First_Name, Last_Name, Gender, Salary, Date_of_Birth, Dept_No
(i) Calculate the sum of salary given to the Teachers and name it as Total_Salary.
(ii) Calculate the maximum and minimum salary of the Teacher and name it as
Max_Salary and Min_Salary.
(iii) Calculate the total number of Teachers whose salary is >40000.

AIM
To write mysql command using AGGREGATE FUNCTIONS to
(i) Calculate the sum of salary given to the Teachers and name it as Total_Salary.
(ii) Calculate the maximum and minimum salary of the Teacher and name it as
Max_Salary and Min_Salary.
(iii) Calculate the total number of Teachers whose salary is >40000.

PROGRAM
mysql > SELECT SUM(Salary) AS Total_Salary FROM Teacher;
OUTPUT

PROGRAM
mysql > SELECT MAX(Salary) AS Max_Salary, MIN(Salary) AS Min_Salary
FROM Teacher;
OUTPUT

PROGRAM
mysql > SELECT COUNT(Salary) FROM Teacher WHERE Salary > 40000;
OUTPUT

JAVA

PROGRAM

(10 MARKS)

01. Write a JAVA program to print the string Hello World.
AIM
To write a JAVA program to print the string Hello World.
PROGRAM
// Your First Program
public class Helloworld {

public static void main(String[] args) {
System.out.println("Hello World");

}
}
OUTPUT

Output from Helloworld
program.

02. Write a Java program to display character A to Z using for loop.

AIM

To write a Java program to display character A to Z using for loop.

PROGRAM

public class CharactersAtoZ {
public static void main(String[] args) {
char c;
for(c = 'A'; c <= 'Z'; c++)
System.out.print(c + " ");
}

}

OUTPUT

03. Write a Java program to check if a given Number is Positive or Negative or Zero
using if..else statement by getting the input of a number of user choice during
runtime.

AIM

To write a Java program to check if a given Number is Positive or Negative or Zero
using if..else statement by getting the input of a number of user choice during
runtime.

PROGRAM

import java.util.Scanner;
public class PositiveNegativeZero {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter the number: ");

int num = reader.nextInt();
// true if number is less than 0
if (num < 0)
System.out.println(+num + " is a negative number.");
// true if number is greater than 0
else if (num > 0)
System.out.println(+num + " is a positive number.");
// if both test expression is evaluated to false
else
System.out.println(+num + " The given number is zero.");

}
}

OUTPUT

04. Write a Java program to find the largest among three numbers using if..else
statement by getting the input of three number of user choice during run time.

AIM

To write a Java program to find the largest among three numbers using if..else
statement by getting the input of three number of user choice during run time.

PROGRAM

import java.util.Scanner;
public class LargestOfThree {
public static void main(String[] args) {

Scanner reader = new Scanner(System.in);
System.out.print("Enter the first number: ");
int n1 = reader.nextInt();
System.out.print("Enter the second number: ");
int n2 = reader.nextInt();
System.out.print("Enter the third number: ");
int n3 = reader.nextInt();
if( n1 >= n2 && n1 >= n3)

System.out.println(n1 + " is the largest number.");
else if (n2 >= n1 && n2 >= n3)

System.out.println(n2 + " is the largest number.");
else

System.out.println(n3 + " is the largest number.");
}
}

OUTPUT

05. Write a Java program to check whether a number is even or odd using if...else
statement by getting the input of a number of user choice during run time.

AIM

To write a Java program to check whether a number is even or odd using if...else
statement by getting the input of a number of user choice during run time.

PROGRAM

import java.util.Scanner;
public class EvenOdd {

public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = reader.nextInt();
if(num % 2 == 0)
System.out.println(num + " is even");
else
System.out.println(num + " is odd");

}
}

OUTPUT

06. Write a Java program to Generate Multiplication Table (number of iteration
(from 1 to 10)) using for loop of a number by getting the input of a number of
user choice during runtime.

AIM

To write a Java program to Generate Multiplication Table (number of iteration
(from 1 to 10) using for loop of a number by getting the input of a number of user
choice during runtime.

PROGRAM

import java.util.Scanner;
public class MultiplicationTable {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter the MultiplicationTable number: ");

int num = reader.nextInt();
for(int i = 1; i <= 10; i++)

{
System.out.printf("%d * %d = %d \n", num, i, num * i);

}
}
}

OUTPUT

07. Write a Java program to find the Area of Rectangle by getting the input of
length and breadth from the user during run time.

AIM

To write a Java program to find the Area of Rectangle by getting the input of length
and breadth from the user during run time.

PROGRAM

import java.util.Scanner;
public class AreaOfRectangle {

public static void main(String args[])
{

Scanner s= new Scanner(System.in);
System.out.println("Enter the length of the Rectangle:");
double l= s.nextDouble();
System.out.println("Enter the width of the Rectangle:");
double b= s.nextDouble();
double area=l*b;
System.out.println("Area of Rectangle is: " + area);
}
}

OUTPUT

08. Write a JAVA program to print the sum of first 10 natural numbers 1 to 10.

AIM

To write a JAVA program to print the sum of first 10 natural numbers 1 to 10.

PROGRAM

public class SumNatural {

public static void main(String[] args) {

int i, sum = 0;

for(i = 1; i <= 10; ++i)
{

sum = sum + i;
}

System.out.println("The Sum of first 10 Natural numbers is = " + sum);
}
}

OUTPUT

09. Write a Java program to print the FIBONACCI SERIES by getting the input of
number of terms in the series during run time.

0 1 1 2 3 5 8 13 21 34
AIM
To write a Java program to print the FIBONACCI SERIES by getting the input of
number of terms in the series during run time.
PROGRAM
import java.util.Scanner;
class Fibonacci
{

public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.println("Enter number of terms");
int n=s.nextInt();
int num1=-1, num2=1,num3=0;
System.out.println("Fibonacci series is ");
for(int i=0;i<n;i++)
{
num3=num1+num2;
num1=num2;
num2=num3;
System.out.print(num3);
System.out.print("\t");
}
}
}

OUTPUT

10. Write a Java program to print the FACTORIAL of a given number by getting

the input of a number of user choice during run time.

AIM

To write a Java program to print the FACTORIAL of a given number by getting the
input of a number of user choice during run time.

PROGRAM

import java.util.Scanner;
public class Factorial {
public static void main(String arg[])

{
int n,fact=1;
Scanner s=new Scanner(System.in);
System.out.println("Enter a number:");
n=s.nextInt();
for(int i=1;i<=n;i++)
{
fact=fact*i;
}
System.out.println("Factorial of the given number "+n +" is " +fact);

}
}

OUTPUT

OPERATING

WEB BASED

APPLICATION

(5 Marks).

CASE STUDY -1
ONLINE BILL CALCULATOR

BOOK RAIL TICKET

How to book train ticket online; step by step guide

Step 1: Visit the IRCTC e-ticketing website: www.irctc.co.in.
Step 2: Login to the IRCTC website by using user id, password
Step 3: You can either login with OTP facility or by entering the captcha code. If
opting the OTP facility, enter the One Time Password (OTP) sent on the registered
mobile number to log in

Step 4: Fill the railway stations between which you wish to travel, ‘source station’
and ‘destination station’ on the ‘Book Your Ticket’ on the homepage of the IRCTC
website.
Step 5: Enter the date of journey and class of travel.

Step 6: The list of trains available on the selected route will be shown.

Step 7: Enter passenger details such as name, age, gender, food choice, seat
preference, mobile number, preferred coach id (if any). Enter the details of the
child, if travelling with senior citizen / children below 5 years of age.

Step 8: Click on ‘Continue Booking’ again on the review booking page. You may
also book a return ticket.

Step 9: Select the payment method from the options available such as credit card,
debit card, net banking, mobile wallet and pay the required amount on payment
window.

Step 10: Electronic Reservation Slip E- Ticket is generated. Passengers must carry a
copy of this E-Ticket while boarding the Train.

“Avoid printing the paper and save trees and our environment”.

Case Study – 2
Online Quiz - Internet and Phone Safety for School Children









You clearly know how to use Internet and Phone Safely
and also Technology wisely!
Well done and keep it up!

Case Study – 3

Online Game – Hangman

Instructions - Playing Hangman

Hangman is a a word game where the goal is simply to find the missing
word or words.

You will be presented with a number of blank spaces representing the
missing letters you need to find.

Use the keyboard to guess a letter.

If your chosen letter exists in the answer, then all places in the answer where
that letter appear will be revealed.

After you've revealed several letters, you may be able to guess what the
answer is and fill in the remaining letters.

Be warned, every time you guess a letter wrong you loose a life and the
hangman begins to appear, piece by piece.

Solve the puzzle before the hangman dies.











THANK
YOU…


Click to View FlipBook Version