0% found this document useful (0 votes)
31 views20 pages

IT - 12th - Lab Manuals - Subject Specific

Uploaded by

almasking0795
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views20 pages

IT - 12th - Lab Manuals - Subject Specific

Uploaded by

almasking0795
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Unit Unit

3: 1:
SPECIFIC
SUBJECT
Fundamentals
Database
SKILLS

Concepts
of
MANUAL)
(LAB
Java
PART B
RDBMS
17
Tool
Ans. between
Managerment
Practical
5. 4. 3. 2. 1.
Item_Id
5. 4. 3. 2. 1. 4006 4005 4004 4003 4002 4001
Selet SelecSelectSelect Display Display
Display Display
Display CONCEPTS-RDBMS
DATABASE
Degree TOOL
Select*
23:
namedistinctnarme * System).
from from name
allthosedistinct
item those all and Rakul
the the
from from PL
B codeItem
item (name) item records items items
records NB PL TP TB SP Cardinality. He has
order item item order made
recently
whose where
where fromwhere in in
by by
descending ascending Pencil Black
NotebookDrawing
Pencil Tooth
Paste Brush
Tooth Soap a
price quantity Write table
price item; name; started
price quantity Name
is t"Item"
he
19 desc; between
is is
order queries working
between is
order more given
>3000
of 20 than of givenbelow. on
p:ice. name.
20 to Quantity RDBMS
and and 100. 3000
7344 8000 10000 2000 8000 5000 below: He
100: <9000: and is
(Relational not
less able
than
Price to
2.67 34.67 1.25 138.90 34.50 71.23 differentiate
UNIT 1
9000. Data-Base
20 Lab Manual Information Technology - 12th
Practical 24: Write the SQL statements for thetable "Trainee" given below:
No Name Monthly_fee Gender Branch id Date of joining
1012 Anmandeep 30000 M A01
2012-01-02
1102 Avisha 25000 F A02
2009-03-24
1103 Ekant 30000 M A02 2011-11-04
1049 Arun 40000 M A02 2009-05-06
1025 Amber 30000 M A02 NULL
1106 Eisha 40000 F A05 2010-11-12
1017 Nikita 35000 F A03 2012-12-04
1108 Arleena 30000 F A03 NULL
1101 Shakthi 25000 M A04 2011-03-23
1. Display the names of applicants whose monthly fee is either 30000 or 40000.
2. Display names and annual fee of all male applicants.
3. Display name, branch id of those who joined in the year 2009.
4. Display the details of those trainees whose date of joining is not
mentioned.
5. Display trainee details in descending order of names.
6. Change the monthly fees of Arleena to 40000.
7. Delete trainee details of those whose mnonthly fee is
30000.
8. Delete those records where the name starts with letter "A"
and ends with letter
"A".
Ans.
1. Select name from players where training fee in (25000,
like "%ball%":
40000) and ganme name
2. Select name from players order by name;
3. Select name, gender, game name from players
where not (game name
= "badminton") ;
4. Sele* from players wheregender="F" and date of join between
2011-01-01"
and "2011-12-31";
5. Select distinct game name from player order by game
name desc;
Subject Specific Skills (Lab Manua) 21
6. Update player set training foe-50000 where name "Arleena",
7. Delete from plaver whee training_ fee=30000;
8. Delete fom player whene game_ name like "GR" and gender= "M";
hactical 25: What willbe the output of the following SQL. statement with reference
to the "Student" table given below:
Table: STUDENT
No. NameStipend Stream Avg-Marks Grade Class
Karan 400,00Medical 78,5 B 12B
2 Divakar 450,00Commerce 89.2 A 11C
3 Divya 300.00 Commerce 68,6 12C
4 Arun 350,00Humanittes 73.1 B 12C
5 Sabina 500,00Non-medical 90.6 A 11A
John 400.00Medical 75.4 B 12B
7 Robert 250.00Humanities 64,4 11A
8 Rubina 450.00 Non-medical 88.5 A 12A
Vikas 500.00 Non-medical 92.0 A 12A
10 Mohan 300.00Commerce 67.5 12C

1. Select Name from Student where not any marks >68;


2. Select Name, stipend from Student where stipend is between 400and 500;
3. Select distinct class from Student;
4. Select Stream, avgmarks from student where stream = nonmedical";
Ans:
1.
Name
Kabeer
2.
Name tution mfee
Reshma 300.00
Sabeena 350.00
Meghna 250.00
Mohan 300.00
Lab Manual Informatlon
Technolouy
Player Name Pay Fee
Kabeer Pay 400,00
Rehmat Pay 450.00
Reshna Pay 300,00
Sabeena Pay 350.00
Shyara Pay 500.00
Mannat Pay 400,00
Meghna 250.00
Pay 450.00
Rubina Pay
Vikas Pay 500.00
Mohan Pay 300.00

Stroam percentage
Commece 68.6

Practical 26: Glven the table CARDEN having following data:


CCode CarName Company Color Capacity Charges
501 A-Star Suzukl Red 3 14
503 Indigo Tata Silver 3 12
502 Innova toyota White 7 15
509 Qualis Toyota Silver 4 14
510 Wagon R Suzuki Red 4 35
Write SQL Conmands for the following:
(a) Display all the details where capacity is more than 3.
(b) Delete the capacitycolumn.
(c) Change the charges to 13 wherecolor is Red.
(d) Displaycar details in ascending order of car name.
Ans.
1. Select * from carden where capacity >3;
2. Delete capacity from carden;
3. Updatecarden set charges -13 where color="red";
4. Select from carden order by
carname;
Subject Specific Skills (Lab Manual) 23

Practical 27: In a Fashion Store's database, there is a table 'Customer' as given below.
Table: Customer
Acc No Cust Name Cust City Cust Phone Open Bal
1001 Dharmesh Ambala 9710557614 10000
1002 Saniya Patna 8223545233 15000
1003 Joe New Delhi 9972136576 13000
1004 Mrinal New Delhi 9321305453 12000
1005 kshaan Agra 9809876798 19000

With reference to, the above given table, what will be the output of following
commands
(a) Select Cust name from Customer where Open bal<=15000;
(b) Select Cust name from Customer where Cust City like %a%';
(c) Select Acc No from Customer where Cust City='New Delhi';
(d) Select Cust name, Acc No from Customer where Acc no is not Null;
Ans.
(a)
Cust Name
Dharmesh
Saniya
Joe
Mrinal
(b)
Dharmesh
|Saniya
|Ikshaan
(d)
Acc No Cust Name
1001 Dharmesh
1002 |Saniya
1003 Joe
1004 Mrinal
1005 Ikshaan
UNIT3
FUNDAMENTALS OFJAVA

Practical 28: White a program to accept integer number from user and print the number
Ans.
import java.util.Scanner;
public class HelloWorld {

public static void main (String [] args) {

Scanner reader new Scanner (System. in) ;


System. out.print (Enter a number: )
int number =
reader.nextInt();
System.out.println ("You entered: " + number) ;

Output
Enter a number: 30
You entered: 30

Practical 29: VWrite a program to accept two numbers from the user and find the sum
of numbers.
Ans.
class Example {

public static void main (String [] args) {

int nl=22, n2=44, Sum;

24
Subject Specific Skills (Lab Manual) 25

sum R nl t n2:

System. out.println (hThe sum is: " + sum) ;

Output
Enter two numbers
34 42
The sum is: 76

Practical 30: Write a program to swap the numbers without using the third variable.
Ans.
public class Swap {

public static void main (String [] args) {

int nl=51, n2=48;


System. out.println ("First number = " + n1)
System. out.println ("Second number = " + n2) ;
nl=n1tn2;
n2=n1-n2;
n1=n1-n2;

System. out.println ("Result")


System. out.println ("First number =
System.out.println ("Second number = " + n2) ;
}

Output
First number = 23
Second number = 78
Result
First number = 78
Second number = 23
26 Lab Manual Information
Technology
Practical 31: Write a program to accept number from the user and
-
12th
number is even or odd. check whether
Ans.
import java.util.Scanner;
public class Example {
public static void main (String [] args) {

Scanner reader = new Scanner (System. in);


System. out.print ("Enter a number: "):
int num = reader.nextInt (0;
if (num % 2 == 0)
System. out.println (num + is even");
else
System. out.println (num + " is odd") :

Output
Enter a number: 22
22 is even

Practical 32: VWrite a program to accept a number from the user and check whether
an alphabet is vowel or consonant.
Ans.
import java.util.Scanner;
public class Example {
public static void main (String[] arg3) {

Scanner reader = new Scanner (System.in) ;


System. out.print ("Enter a character: ");
char ch = reader. next (). charAt (0) ;

if (ch == 'a' | ch = 'e' | | ch == i' | ch == 'o | ch == 'u' )


System. out.println (ch + " is vowel");
else

26
Manua) 27
Subject Specific Skills (Lab
System. out.println (ch + is consonant"):

Output
Enter a character:
a is vONel

Practical 33: Write a program to accept three numbers from the user and find the
largest number.
Ans.
public class Example {
public static void main (String [] args) {

Scanner reader = new Scanner (System. in) ;


System. out.print ("Enter a lst number: ");
char nl = reader.nextInt ();

System. out.print ("Enter a 2nd number: ");


char n2 = reader.nextInt () ;

System. out.print ("Enter a 3rd number: ");


char n3 = reader.nextInt () i

if( nl >= n2 && nl >= n3)


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

else if (n2 >= n1)


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

else
number");
System, out.println(n3 + " is the largest
28 Lab Menual Informnt.lon lhohnology 12u
Output
Enter a lat number 7
Enter a 2nd number : 3
Enter a 3rd number: 9
9 1a the largest number

Practical 34:Wrlte a program locheck leap year.


Ans.
publla olass Example (

publia statia vold main (8tring[] args) {


Lnt year 2022 ;
boolean loap false;
if (year 8 4 0) {
if (year % 100 0) (
1£ (year t 400 0)
loap true;
olse
leap talse ;

olse
leap true;

else
leap false;

if (leap)
System. out.println (yoar + " is a leap yoar, ");
else
System, out.println (year + " Ls not a leap yoar");
)
29
Subject Specific Skills (Lab Manual)
Output
2022 is not a leap year
Practical 35: Write a program to check whethera number is positive or negative.
Ans.
public class Example {

public static void main (String [] args) {

double n1 = 18;

if (number < 0.0)


System.out.println (number + " is a negative number");

else if ( number > 0.0)


System. out.println (number + " is a positive number") ;

else

System. out.println (number + " is 0") :

Output
18 is a positive nunber
Practical 36: Write a program to check whether a character is alphabet or not.
Ans.
public class Example {

args) {
public static void main (String[]

char c = 'a';

'a' s& C K= 'z') | | (c = 'A' && c <= 'Z'))


i£( (c
System. out.println (c + is an alphabet");
else
30 Lab Manual Infornatlon
System, out.println(a + " ds not an alphabat" ):
Tochnology- 12uh

Output
a ls an alphabet

Practical 37: Write a programto Find the Factorial of aNumber n = 1 "2 3 4


Ans.
public class Example {

public statia void main (String [] args) {

0nt num = 10;

long f =l;
for (int i = 1; <= num; +i)

f = f * i;

System. out.print£(Eactorial of a number ", £);

Output
Factorial of a number = 3628800

Practical 38: Write a program to find the length of the string.


Ans.
public class Example {
public static void main (string [] args) {
String str="Ashish" ;

int len=str.length () ;
Subject Specific Skills (Lab Manual)
System. out.println(len):

Output -
6

Practical 39: Wite a program to check whether the string is palindrome or not.
Ans.
class Example {
public static void main (string[] args) (
String str = RADAR", r str = *;
int strLength;

int striength = str.length () ;

for (int i = (striength - 1); i S=0; i--) {


r str = r str t str. charAt (i) ;

if (str. toLowerCase () .equals (r_ str.toLowerCase ())) {


System, out.println (str + " is a Palindrome") :

else {
System, out.println (str + " is not a Palindrome") :

Output
RADAR is a Palindrome

Practical 40. Write a program to check whether a number is prime or not.


Ans.
public class Example {
32 Lab Manual Information Technology - 12x
public static void main (String[] args) {

int num = 3;
boolean £ = false;
£or (int i = 2; i <= num / 2; it+) {
if (num % i = 0) {
£= true;
break ;

if (!£)
System.out.println (num + is a prime number") ;
else

System.out.println (num + " is not a prime number") ;

Output
3 is a prime number

Practical 41:Write a program to design simple calculator using switch statement.


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

char ch;
Double numberl, nunber2, result;

Scanner input = new Scanner (System. in);

System, out.println ("Choose an operator: +, -, *, or /") ;


System. out.println("1. +") ;
System. out.println ("2. -");
Subject Specific Skills (Lab Manual) 33
System. out.println ("3. *"):
System. out.println ("4. /"):

System. out.println (" Select ahoice");

ch = input.next () .charAt (0) :

System. out.println("Enter flrst number"):


number1 = input.nextDouble(0:
System. out. println("Enter second number") :
number2 = input.nextDouble () :

switch (ch) {

case +:

result = numberl + number2;


System, out.println (number1 + " + " t number2 +t " = " + result) ;
break ;

Case

result = number1 - number2;


System.out.println (numberl + " - " + number2 + " + result) ;
break;

Case

result = number1 * number2;


System. out.println (number1 + " * + number2 + " = " + result) ;
break ;

case ' / :
result = numberl / number2 ;
System. out.println(number1 + " / + number2 + " = " + result):
break;:
34 Lab Manual Information Technology -12th
default:

System.out.println ("Invalid choice!") ;


break;

input.close () ;

Output
1. +
2. -
3. *

4. /
Select Choice +
Enter frst number 14
Enter second number 6
14 *6 = 20

Practical 42: Write a Java program to print the Fibonacci Series by getting input of
the number of terms in the series during run time.
0112358 13 2134
Ans.
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;it+)
Subject Specific Skills (Lab Manual) 35

num3=num1+num2 :
numl=num2;
num2=num3;
System. out. print (num3) :
System. out.print ("\t") ;

Practical 43: Write a program to find the average of the given array 27, 38, 57, 84, 64.
Ans.
public class Example {

public static void main (Stringl] args) {


int[] numArray = { 27, 38, 57, 84,64);
double sum 0;

for (double num: numArray) {


sum t= num;

double average = sum / numArray. length ;


System.out.format ("The average is + average) i

Output -
The average is: 54.0
Practical 44: Write a program to concatenate two different strings.
Ans.
public class Example {
public static void main (String [] args) {
String strl="Ashish ";
String str2="Anand" ;
36 Lab Manual Informention hahnology
12

string str=strl.concat (str2):

System. out println (str3) :

Output
Ashish Anand
Practical 45: Write a program to convert the string into uppercase format.
Ans.
public class Example {
public static void main (StringI] args) {
String str-"anurag":

String upper=str.toUpperCase () ;

System, out.println (upper) ;

Output
ANURAG

Practical 46:Write a Java program to find the Area of aRectangle by geting the inputof
length and breadth from the user during run tÉme.
Ans:
import java.util.Scanner;
public class AreaOfRectangle {
public static void main (String args [])

Scanner g= new Scanner (System. in) ;


36
Subject Specific Skills (Lab Manual) 37

System. out.println ("Enter the 1ength of the Rectangle:");


double l= s. nextDouble ():
System. out.println ("Enter the width of the Rectangle:");
double b= s.nextDouble () ;
double area=1*b;

System.out. println("Area of Rectangle is: " + area) ;


)

Practical 47: Write a Java program to display character A to Z using for loop.
Ans:
public class CharactersAtoZ {
public static void main (String [ args) {
char c;

for (c = 'A'; c <= Z'; c++)


System. out.print (c + ");
)

You might also like