You are on page 1of 110

St.Raphael’s H.S.

School

CERTIFICATE
This is to certify that …………..a student of class
XII-D (COMMERCE) of St. Raphael’s Higher
Secondary School, Indore has completed
Informatics Practices (IP) Practical Assignments.
It is a bona fide piece of work under my
supervision and guidance. To the best of my
knowledge it is the original work of the candidate
and is a result of her own efforts in the partial
fulfillment of the requirement as per CBSE
curriculum of class XII (IP).

__________ Mr. Manoj Thomas

External Internal

1
St.Raphael’s H.S. School

CERTIFICATE
This is to certify that ………………… a student of
class XII-D (COMMERCE) of St. Raphael’s Higher
Secondary School, Indore (Session 2017-18) has
completed Informatics Practices (IP) Practical
Assignments.
It is a bona fide piece of work under the guidance
of ‘Mr.Manoj Thomas’ IP lecturer of St. Raphael
H.S School in the partial fulfillment of the
requirement as per CBSE curriculum of class XII
(IP).

Date: Sr. Preethi Thomas


Principal

2
St.Raphael’s H.S. School

ACKNOWLEDGEMENT

I a student of class 12th COMMERCE deeply


acknowledge the guidance and help given by my
respected teacher of IP “Mr. Manoj Thomas” in
completion of this project file. I express my
sincere gratitude for the encouragement and help
given during the course of this project. I also
thank our Principal “Sr. Preethi Thomas” for her
encouragement and help from time to time during
my tenure as a student of class 12th.

3
St.Raphael’s H.S. School

JAVA PROGRAMMES

4
St.Raphael’s H.S. School
Q1. Write a program to check whether the given number is a multiple of
3, 5 or 7?

Q2. Design a GUI


application to accept the cost price and selling price form the user intwo
text fields then calculate the profit or loss incurred in a label.

5
St.Raphael’s H.S. School

Q3.Design a GUI application to accept a character in a text field and print


in a label if that character is a vowel: a, e, i, o, or u. the application
should be case sensitive.

6
St.Raphael’s H.S. School

7
St.Raphael’s H.S. School
Q4.Design a GUI application in which the user enters a number in the text
field and on clicking the button the sum of the digits of the number should
be displayed in a label. Hint : Suppose user enters 123 the output should
be 6(1+2+3).

Q5.Create a GUI application to accept 3 numbers in separate text fields


and display their sum, average, maximum or minimum after rounding the

8
St.Raphael’s H.S. School
results on the click of appropriate buttons (There are four radio buttons -
one for sum, one for average, one for maximum and one for minimum). The
result should be displayed in the fourth text field.

Q6.De
sign a
GUI

application in java to convert kilograms into grams, litres into


milliliters, rupees into paisa using combobox and Label

9
St.Raphael’s H.S. School
Q7. To calculate selling price depending upon profit margin

10
St.Raphael’s H.S. School

Q8.Design the following application

11
St.Raphael’s H.S. School

. Q9.Develop an application as shown below

12
St.Raphael’s H.S. School

Q10.A book publishing house decided to go in for computerization. The


database will be maintained at the back end but you have to design the

13
St.Raphael’s H.S. School
front end for the company. You have to accept book code, Title, Author
and Quantity sold from the user. The Price will be generated depending
upon the book code. Net price should be calculated on the basis of the
discount given.
Bookseller - 25%
School - 20%
Customer - 5%

14
St.Raphael’s H.S. School

Q11. Design a GUI application in java to convert temperature from Celsius


to Fahrenheit or vice versa using radio buttons and two text fields.

15
St.Raphael’s H.S. School

Q12.Create a GUI application to accept the date (as 1), month (as a
number like 3 for March) and year (as 2010) in separate text fields and
display the date in the format:dd/mm/yy

16
St.Raphael’s H.S. School

Q13. Create an application that calculates the power of a number.

17
St.Raphael’s H.S. School

Q14. Design the application as shown

18
St.Raphael’s H.S. School

QUES 15 : Design a GUI application to accept a String from the user


in a text field and print using option pane whether it is a palindrome or
not.
Hint ABBA is a palindrome.

19
St.Raphael’s H.S. School

Ques 16 : Design the appli. To round off a number.

20
St.Raphael’s H.S. School

Q17.Develop a "Case Changer" application as shown below

21
St.Raphael’s H.S. School

Ques 18 : Develop an application to accept first name , last name , middle


name from the user and display his short name.

22
St.Raphael’s H.S. School

Ques19. Design a GUI application to calculate factorial of a number.

23
St.Raphael’s H.S. School

Ques 20 : Develop an application to accept two strings – first name and


last name and display the message welcome with the complete name of the
user.

24
St.Raphael’s H.S. School

Q21.Design a GUI Application to accept a Number in a Text Field and


Display all the odd numbers less than number entered in a Text Area.

25
St.Raphael’s H.S. School

Ques 22 : Develop an application to reverse the given number and also


find out whether the number is a palindrome or not.

26
St.Raphael’s H.S. School
QUES 23 : Develop an application to display the no. of occurance of a
particular letter in a particular word .

Q24.Create an application to accept the radius of a circle, calculate the


area and
circumference and display the results in a message box after rounding off
the area and circumference to an integer number.

27
St.Raphael’s H.S. School

Q25.Develop an application to reverse the given number and also find out
whether
the number is a palindrome or not.

28
St.Raphael’s H.S. School

Q26. Create a GUI application to accept a string and display it in reverse


order using the substring() method.

Q27. To calculate sum of natural numbers to the number entered by user.

29
St.Raphael’s H.S. School

Q28. Develop an application as shown below

30
St.Raphael’s H.S. School

Q29.Design a GUI Application to accept sales from Salesman and Calculate


the commission based on following condition.

31
St.Raphael’s H.S. School
Sales Commission Rate
30001 onwards 15%
22001-30001 10%
12001-22000 7%
5001-12000 3%
0-5000 0%
Commission should be displayed in a Label.

Q30. Design a GUI Application to accept a Number in a Text Field and


display all the odd numbers less than number entered in a Text field.

32
St.Raphael’s H.S. School

Q31.Design a GUI Application to accept month number in a Text Field and


Display respective month name and days of that month using Switch case
statement.

33
St.Raphael’s H.S. School

Q32.Design a GUI Application to Calculate Total Price of Books given below

34
St.Raphael’s H.S. School
Q33.Design the following application to show day of the week:

Q34. Design a GUI to Calculate result.

35
St.Raphael’s H.S. School

36
St.Raphael’s H.S. School

JAVA APPLICATION AND DATABASE CONNECTIVTY

Q1.Design the following application to find the total bill.If the quantity
field is left empty it should show a massage that field cannot left
empty.Also Save the data in Item table.

37
St.Raphael’s H.S. School

38
St.Raphael’s H.S. School
Q2. Design the following application

Platinum members get a discount of 10% on all their purchases, gold


members get 5% and Silver members get 3% discount.

Also Save the data in Shop table.

39
St.Raphael’s H.S. School

Q3.Devlop a Contact List Application.

40
St.Raphael’s H.S. School

41
St.Raphael’s H.S. School

42
St.Raphael’s H.S. School

43
St.Raphael’s H.S. School

My-Sql Programmes

Q1 .Consider the following tables STOCK and DEALERS and write


the queries for (i) to (iv) and output for (v):

44
St.Raphael’s H.S. School
Table : STOCK

Itcode Itname Dcode Qty unitpr Stkdate

444 Drawing Copy 101 110 21 31-July-


2010

445 Sharpener 102 235 3 01-Aug-2010


Camlin

450 Eraser Natraj 101 40 2 17-Aug-2010

452 Gel Pen Montex 103 50 5 30-Dec-2009

457 Geometry Box 101 35 45 15-Nov-2009

467 Parker Premium 102 60 205 27-Oct-2009

469 Office File 103 32 25 13-Sep-2010

Table : DEALERS

Dcode Dname

101 Vikash Stationers

102 Bharat Drawing Emporium

103 Banaras Books Corporation

(i) To display details of all items in the stock table in descending order
of Stkdate.

45
St.Raphael’s H.S. School

(ii)To increase unitpr (unit price) by 20% in the stock table for the items
which has been purchased before 2010.

(iii) To display the details of those items whoseDcode (Dealer Code) is 102
or Qty (Quantity) is more than 50 from the table stock.

(iv) To display minimum unit price of items for each dealer individually as
per Dealer Code from the table stock.

46
St.Raphael’s H.S. School

(v) SELECT COUNT(DISTINCT Dcode)FROM STOCK;

Q2. Create the following tables Product and Client.Write SQL commands
Table : Product

P_ID ProductName Manufacturer Price

TP01 Talcom Powder LAK 40

FW0 Face Wash ABC 45


5

BS01 Bath Soap ABC 55

SH06 Shampoo XYZ 120

FW1 Face Wash XYZ 95


2

47
St.Raphael’s H.S. School

Table : Client

C_ID ClientName City P_ID

01 Cosmetic Shop Delhi FW05

06 Total Health Mumbai BS01

12 Live Life Delhi SH06

15 Pretty Woman Delhi FW12

16 Dreams Banglor TP01


e

(a) To display the details of those clients whose city is not Delhi.

(b) To display the Client name, City From table Client and Product
Name and Price from table Product, with their corresponding matching
P_ID.

48
St.Raphael’s H.S. School

(c)To display the details of those client whose City is Banglore.

(d) To display the details of Products whose Price is in the range of


50 to 100 (Both value included).

(e) To increase the Price of all Product by 25%.

49
St.Raphael’s H.S. School

Q3.Create the following tables Doctor and Salary and execute the SQL
Commands

DOCTOR

ID NAME DEPT SEX EXPERIENCE

101 John ENT M 12

104 Smith ORRHPEDIC M 5

107 George CARDIOLOGY M 10

114 Lara SKIN F 3

109 K George MEDICINE F 9

105 Johnson ORRHPEDIC M 10

117 Lucy ENT F 3

111 Bill MEDICINE F 12

130 Morphy ORRHPEDIC M 15

50
St.Raphael’s H.S. School

Table :SALARY

ID BASIC ALLOWANCE CONSULTATION

101 12000 1000 300

104 23000 2300 500

107 32000 4000 500

114 12000 5200 100

109 42000 1700 200

105 18900 1690 300

130 21700 2600 300

(a). Display NAME of all doctors who are in “MEDICINE” having more than
10 years experience and basic more than 10000.

(b). Display the average salary of all doctors working in “ENT” department
using DOCTOR table where as salary=basic + allowance

51
St.Raphael’s H.S. School
(c). Display the minimum ALLOWANCE of female doctors.

(d). Display the highest consultation fee among all male doctors.

(e). Display the total number of doctors in ORRHPEDIC department.

Q4. Consider the following tables and answer the following:

EMPLOYEE

W_I FIRSTNA LASTNAM


CITY
D ME E

102 SAM TONES PARIS

ACKERMA
105 SARAH NEW YORK
N

SENGUPT
144 MANILA NEW DELHI
A

52
St.Raphael’s H.S. School
210 GEORGE SMITH HOWARD

DESIGN

W_I SALAR BENEFI DESIGNATI

D Y TS ON

102 75000 15000 MANAGER

300 45000 10000 CLERK

335 40000 10000 CLERK

400 32000 7500 SALESMAN

451 28000 7500 SALESMAN

i). Display FirstName and City of Employee of PARIS

ii). Display W_ID, salary and designation of all SALESMAN.

iii). Increase the benefits of employee having W_ID = 102 by 1500.

53
St.Raphael’s H.S. School

iv). Count number of employees city wise.

v). Select COUNT(DISTINCT designation) from design;

Q5.Consider the tables ITEMS&COMPANY. Write SQL commands for the


statements (i) to (iv) and give the outputs for SQL queries (v)
Table : ITEMS

ID PNAME PRICE MDATE QTY

T001 Soap 12.00 11/03/2007 200

T002 Paste 39.50 23/12/2006 55

T003 Deodorant 125.00 12/06/2007 46

T004 Hair Oil 28.75 25/09/2007 325

T005 Cold 66.00 09/10/2007 144


54
St.Raphael’s H.S. School
Cream

T006 Tooth 25.00 17/02/2006 455


Brush

Table : COMPANY
ID COMP City

T001 HLL Mumbai

T006 Colgate Delhi

T009 HLL Mumbai

T007 Paras Haryana

T005 Ponds Noida

T0011 Wipro Ahmedabad

i) Display the items detail produced by Wipro & Paras.

ii) To display product name, company name & price for those items,
which IDs are equal to the IDs of company.

iii) To delete the items produced before 2007.

55
St.Raphael’s H.S. School

iv) To display the total stock value of items.

v) SELECT comp, city FROM company order by city;

Q6.Consider the following table CLUB and MEMBER. Write the SQL
commands for the statements (i) to (iv) and output (v).

56
St.Raphael’s H.S. School
Table: CLUB

GCode GameName Number Fees StrtingDate

101 Carom 2 5000 23-Jan-


Board 2004

102 Badminton 2 12000 12-Dec-


2003

103 Table 4 8000 14-Feb-


Tennis 2004

105 Chess 2 9000 01-Jan-


2004

108 Lawn Tennis 4 25000 19-Mar-


2004

Table: MEMBER

Code Name GCode

1 Nabi Ahmad 101

2 Ravi Sahai 108

3 Jasvinder 101

4 Robert 103

(i) To display the name of all the games with their GCodes.

57
St.Raphael’s H.S. School

(ii) To display all information of those games which are having fees more
than 10000.

(iii)To display the information of CLUB table in descending order of


StartDate.

(iv) To display Name and Number of All the members from the Table
CLUB and MEMBER.

58
St.Raphael’s H.S. School

(v) SELECT COUNT(DISTINCT Number) FROM CLUB;

Q7. Write SQL Commands for (i) to (iv) and write the outputs for (v) on
the basis of table :
Table : FURNITURE

NO ITEM NAME TYPE DATEOFSTOCK PRICE DISCOUNT

1 White Lotus Double 2002-02-23 3000 25


Bed

2 Pink Baby Cot 2002-01-29 7000 20


feathers

3 Dolphin Baby Cot 2002-02-19 9500 20

4 Decent Office 2002-02-01 25000 30


Table
59
St.Raphael’s H.S. School
5 Comfort zone Double 2002-02-12 25000 30
Bed

6 Donald Baby cot 2002-02-24 6500 15

7 Royal Finish Office 2002-02-20 18000 30


Table

8 Royal tiger Sofa 2002-02-22 31000 30

9 Econo sitting Sofa 2001-12-13 9500 25

10 EatinParadis Dinning 2002-12-19 11500 25


e Table

i. To show all the information about the Baby cots from the furniture
table.

ii. To list the itemname which are priced at more than 15000 from the
furniture table.

iii. To list itemname and type of those items, in which dateofstock is


before 2002-02-01 from the furniture table in descending order of
itemname.

60
St.Raphael’s H.S. School

iv. To display itemname and dateofstock of those items, in which the


discount percentage is more than 25 from the furniture table.

v. To count the number of items, whose TYPE is “Sofa” from the


furniture table.

Q8. Write the SQL commands for the i) to iv) and write the output of
the (vi) on the basis of table TEACHER.
Table:TEACHER

61
St.Raphael’s H.S. School
No Name Age Departmen Dateofapp Salary Sex
. t

1 Jugal 34 Computer 10/01/97 12000 M

2 Sharmila 31 History 24/03/98 20000 F

3 Sandeep 32 Maths 12/12/96 30000 M

4 Sangeeta 35 History 01/07/99 40000 F

5 Rakesh 42 Maths 05/09/97 25000 M

6 Shyam 50 History 37/06/98 30000 M

7 Shivam 44 Computer 25/02/97 21000 M

8 Shalakha 33 Maths 31/07/97 20000 F

i) To show all information about the teacher of History department.

ii) To list the names of female teachers who are in Maths


department.

iii) To list names of all teachers with their date of appointment in


descending order.
62
St.Raphael’s H.S. School

iv) To insert a new row in the TEACHER table with the following data:
9,’Raja’, 26,’Computer’, {13/05/95}, 23000,’M’

v) Write create statement to create above table by taking proper


data types.

vi) Give the output of the following SQL statements.

a. Select COUNT(distinct department) from TEACHER;

b. Select MAX(Age) from TEACHER where SEX=’F’;

c. Select AVG(Salary) from TEACHER where SEX=’M’;

63
St.Raphael’s H.S. School

d. Select SUM(Salary) from TEACHER where


DATOFJOIN<{12/07/96};

Q9.Consider the following tables EMPLOYEE and SALARIES. Write SQL


commands for the statements (i) to (iv) and give outputs for SQL queries
(v) to (viii)

TABLE: EMPLOYEE

EMPID EMPNAME SECTION SEX EXPERIENCE

101 Sabeena PRODUCTION F 10

102 Siva ACCOUNTS M 15

103 Ayaz INSPECTION M 10

104 Gayathri PRODUCTION F 8

TABLE: SALARIES

EMPID SALARY INCENTIVE ALLOWANCE

101 18000 1800 1325

103 23150 3100 1121

105 13120 2300 1240

64
St.Raphael’s H.S. School

106 12550 1250 1005

i. Display EMPNAME of all staff who are in “ACCOUNTS” having more


than 10 years experience from the table EMPLOYEE.

ii. Display the average PAY of all staff working in “INSPECTION”


department using the tables EMPLOYEE and SALARIES.

iii.Display the minimum INCENTIVE of female staff.

iv.Display the highest ALLOWANCE among all male staff.

65
St.Raphael’s H.S. School
v. SELECT count (*) from EMPLOYEE where SEX = “F”.

vi.SELECT EMPNAME, SECTION, ALLOWANCE from EMPLOYEE,


SALARIES where SECTION = “ACCOUNTS” and EMPLOYEE.EMPID =
SALARIES.EMPID;

vii. SELECT EMPNAME from EMPLOYEE where SECTION=


INSPECTION and SEX=’M’;

viii. Select count (distinct SECTION) from EMPLOYEE;

Q10. Read the instructions given below and answer accordingly: (MySql)
Write MySql commands for (i) to (x) based on the following table.

SUPPLIERS

SCOD SNAME CITY STATE AMOU


66
St.Raphael’s H.S. School
E NT

1 RAJESH BHIKHIWI PUNJAB 5000


ND

2 RAJAT AMRITSAR PUNJAB 5400

3 PUNEET SONIPAT HARYANA 6200

4 RACHN FARIDABA HARYANA 8400


A D

5 RAMAN JAMUNAN HARYANA 8940


AGAR

6 PRAGTI BISHRAMP CHATTISGA 4800


UR RH

7 PRAHAL BABRALA UTTER 3000


AD PARDESH

8 KOCHER LAKHERI RAJASTHA 2500


N

i) Show sname of suppliers whose name is starting with letter ‘P’

ii) Show sname, city of suppliers who belongs to ‘PUNJAB’

67
St.Raphael’s H.S. School

iii) Show sname of suppliers in descending order.

iv) Show sname, city of suppliers who belongs to either ‘HARYANA’ or


‘PUNJAB’

v) Change the amount to 5000 where scode is 1008.

vi) Delete the suppliers from SUPPLIERS table who belongs to state
‘UTTAR PARDESH’.

68
St.Raphael’s H.S. School

vii) Insert a new record in SUPPLIERS table with following description:


1009, ‘NEETA ARORA’,’DELHI’, ‘DELHI’,7500

viii) Add a new column (COMMISSION DECIMAL(7,2)) in the above


table.

ix) Display total no. of records in table.

x) Display no. of employees in each city.

Q11.Consider the table Flight given below, write command in SQL for (1)
to (4) and output for (5) to (8).

69
St.Raphael’s H.S. School
Table :FLIGHT

Flight_N Origin Destinati Seat FlightDat Rat


o on s e e

1005 Varana Nepal 275 12-Dec- 300


si 07 0

2785 Delhi Kerala 290 17-Jan- 550


08 0

6587 Mumbai Varanasi 435 19-Feb- 500


08 0

1265 Varana Nepal 200 02-Jan- 540


si 08 0

4457 Delhi Lucknow 150 22-Feb- 450


08 0

6856 Varana Mumbai 180 03-Mar- 600


si 08 0

(1) To display Flight flying between Varanasi and Nepal.

(2) To display the different Origin of Flights.

70
St.Raphael’s H.S. School

(3) To display list of flights in descending order of Rate.

(4) To display flight details of the flight whose flightdate is after


Jan 2008.

(5) SELECT Flight_No, Destination FROM Flight WHERE Destination


LIKE ‘_u%’;

(6) SELECT Origin, COUNT(*) FROM Flight GROUP BY Origin;

71
St.Raphael’s H.S. School

(7) SELECT Origin, Destination FROM Flight WHERE seats>400;

(8) SELECT SUM(Rate),MAX( Seats) FROM Flight;

Q12. Consider the following table named “GYM” with details about fitness
items being sold in the store.Write command of SQL for (i) to (iv) and
output for (v) to (vii)

Table :GYM

ICODE INAME PRICE BRANDNAME

G101 Power Fit 20000 Power Gymea


Exerciser

G102 Aquafit Hand 1800 Reliable


Grip

G103 Cycle Bike 14000 Ecobike


72
St.Raphael’s H.S. School

G104 Protoner 30000 Coscore


Extreme Gym

G105 Message Belt 5000 MessagExpert

G106 Cross Trainer 13000 GTCFitness

(i)To display the names of all the items whose name starts with “A”.

(ii)To display ICODEs and INAMEs of all items,whoseBrandname is Reliable


or Coscore.

(iii) To change the Brandname to “Fit trend India” of the item. Whose
ICODE as “G101”.

(iv) Add a new row for a new item in GYM with the details: “G107”,”Vibro
exerciser’,21000,”GTCFitness”

(v) SELECT COUNT(DISTINCT(BRANDNAME)) FROM GYM;

73
St.Raphael’s H.S. School

(vi) SELECT MAX(PRICE) FROM GYM;

(vii) SELECT INAME FROM GYM WHERE INAME LIKE “%T”;

Q13.

74
St.Raphael’s H.S. School

i)

ii)

75
St.Raphael’s H.S. School

iii)

Q14.

76
St.Raphael’s H.S. School

77
St.Raphael’s H.S. School

6.

78
St.Raphael’s H.S. School

Q15.

79
St.Raphael’s H.S. School

Q16

80
St.Raphael’s H.S. School

Q17

1.

81
St.Raphael’s H.S. School

2.

3.

4.

5.

82
St.Raphael’s H.S. School

6.

7.

Q18.Write SQL commands for (i) to (v) on the basis of the table
Student1.

Student No Class Name Game1 Grade Game2 Grade

10 7 Abhishek Cricket B Swimming A

11 8 Sujit Tennis A Skating C

12 7 Kamal Swimming B Football B

13 7 Archana Tennis C Tennis A

14 9 Arpita Basket Ball A Cricket A

15 10 Dona Cricket A Athletics C

i) Display the name of the students who have grade ‘C’ in either
Game1 or Game2 or both.

83
St.Raphael’s H.S. School

ii) Display the number of students getting grade ‘A’ in Cricket.

iii) Display the names of the students who have same game for both
Game1 and Game2

iv) Display the games taken by the students, whose name starts with
‘A’.

v) Add a new column ‘marks’.

Q19.

84
St.Raphael’s H.S. School

85
St.Raphael’s H.S. School

Q20.

i. Select Pname from fitness where Price>20000;

ii. Select Pname from fitness where manufacturer=’Aone’;

iii. Update fitness set price=price-price*0.25;

86
St.Raphael’s H.S. School

iv. Insert into fitness values(‘P7’,’Vibro Exerciser’,28000,’Aone’);


Output:

v.

87
St.Raphael’s H.S. School

HTML WEBSITE

88
St.Raphael’s H.S. School

<html>

<head>

<title></title>

</head>

<body background="stars.jpg">

<h1><center><font size=7 font face="Elephant" color="white">SOME


POPULAR WEBSITES</center></h1><br><br>

<marquee scrollamount=20%><a href="food.html"><img


src="fp.jpg"height=250 width=350></a>&nbsp;&nbsp;&nbsp;

<a href="hots.html"><img src="hots.jpg" height=250


width=300></a>&nbsp;&nbsp;&nbsp;

<a href="ABP.html"><img src="abp.jpg"height=250


width=300></a>&nbsp;&nbsp;&nbsp;

89
St.Raphael’s H.S. School

<a href="pay.html"><img src="pay.png"height=250


width=350></a>&nbsp;&nbsp;&nbsp;

<a href="abof.html"><img src="abof.jpg"height=250


width=350></a>&nbsp;&nbsp;&nbsp;

<a href="wu.html"><img src="wu.png"height=250


width=350></a>&nbsp;&nbsp;&nbsp;

<a href="feedback.html"><img src="cuty.jpg"height=250


width=350></a>&nbsp;&nbsp;&nbsp;

</marquee>

</body>

</html>

90
St.Raphael’s H.S. School

91
St.Raphael’s H.S. School

JAVA PROJECT(PIZZA HUT)

92
St.Raphael’s H.S. School

CLICK TO ENTER INTO THE WORLD OF PIZZAS:-

members_login a=new members_login();

93
St.Raphael’s H.S. School
a.setVisible(true);

this.setVisible(false);

NEW TO PIZZA HUT:-


register a=new register ();

a.setVisible(true);

this.setVisible(false);

LOGIN:-
boolean option=false;

try

String email = jTextField1.getText();

String pass = new String(jPasswordField1.getPassword());

94
St.Raphael’s H.S. School
Class.forName("java.sql.Driver");

Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/pizzahut","root","tiger
");

Statement stmt= con.createStatement();

ResultSet rs = stmt.executeQuery("select email,password from


register;");

while(rs.next()){

String u = rs.getString(1);

String p = rs.getString("password");

if(email.equals(u)&&p.equals(pass))

JOptionPane.showMessageDialog(null,"You Have Signed In


Successfully");

option=true;

ordernow o=new ordernow();

this.setVisible(false);

o.setVisible(true);

if(option==false)

95
St.Raphael’s H.S. School
{

JOptionPane.showMessageDialog(null,"wrong ");

jTextField1.setText("");

jPasswordField1.setText("");

rs.close();

stmt.close();

con.close();

catch(Exception e)

{JOptionPane.showMessageDialog(null,e.getMessage());}

CLEAR:-
jTextField1.setText("");

jPasswordField1.setText("");

96
St.Raphael’s H.S. School

SAVE:-
try{

String name= jTextField1.getText();

String add= jTextField2.getText();

String pass= new String(jPasswordField1.getPassword());

97
St.Raphael’s H.S. School
String email= jTextField3.getText();

String city= jTextField4.getText();

String mob= jTextField5.getText();

Class.forName("java.sql.Driver");

Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/pizzahut","root","
tiger");

String sql="insert into register values('"+ name + "', '"+city + "' , '" +
pass + "' , '"+ add +"' , '"+ email +"' , '"+ mob + "' );";

Statement stmt=con.createStatement();

stmt.executeUpdate(sql);

JOptionPane.showMessageDialog(null,"RECORD SAVED");

members_login m=new members_login();

this.setVisible(false);

m.setVisible(true);

con.close();

stmt.close();

jTextField1.setText("");

}catch(Exception e)

JOptionPane.showMessageDialog(null,e);

98
St.Raphael’s H.S. School
}

CLEAR:-
jTextField1.setText("");

jTextField2.setText("");

jTextField3.setText("");

jTextField5.setText("");

jPasswordField1.setText("");

99
St.Raphael’s H.S. School

PIZZAS:-
pizzas p =new pizzas();

this.setVisible(false);

p.setVisible(true);

100
St.Raphael’s H.S. School

CONFIRM ORDER:-
bill a=new bill ();

a.setVisible(true);

this.setVisible(false);

import java.sql.*;

public void save(String s,int p)

try{

101
St.Raphael’s H.S. School

Class.forName("java.sql.Driver");

Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/pizzahut","root","
tiger");

String sql="insert into order1 values('"+ s + "', "+p + ");";

Statement stmt=con.createStatement();

stmt.executeUpdate(sql);

con.close();

stmt.close();

catch(Exception e)

JOptionPane.showMessageDialog(null,e);

jButton1:-
String name="TOMATO PIZZA";

int price=250;

save(name,price);

102
St.Raphael’s H.S. School
jButton2:-
String name="ULTIMATE PANEER";

int price=250;

save(name,price);

jButton3:-

String name="ULTIMATE VEGGIE";

int price=300;

save(name,price);

jButton4:-
String name="EXOTICA";

int price=400;

save(name,price);

jButton5:-
String name="ULTIMATE PANEER";

int price=250;

save(name,price);

103
St.Raphael’s H.S. School
jButton6:-
String name="FIERY RIDE";

int price=250;

save(name,price);

jButton7:-
String name="DOUBLE CHEESE PIZZA";

int price=400;

save(name,price);

jButton8:-
String name="TANDOORI PIZZA";

int price=350;

save(name,price);

jButton9:-
String name="CHEESY OLIVE PIZZA";

int price=250;

save(name,price);

104
St.Raphael’s H.S. School

GENERATE BILL:-
int count=1;

try

Class.forName("java.sql.Driver");

Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/pizzahut","root","tiger
");

105
St.Raphael’s H.S. School
Statement stmt= con.createStatement();

ResultSet rs = stmt.executeQuery("select name,price from


order1;");

DefaultTableModel d=(DefaultTableModel)jTable1.getModel();

d.getDataVector().removeAllElements();

while(rs.next()){

String n=rs.getString(1);

int p=rs.getInt(2);

DefaultTableModel t=(DefaultTableModel)jTable1.getModel();

Object[] a={n,p};

t.addRow(a);

int rows=jTable1.getRowCount();

int tp=0;

for(int row=0;row<rows;row++)

String total=(String)(""+jTable1.getValueAt(row,1));

tp+=Integer.parseInt(total);

jTextField7.setText(""+tp);

String sql1="select bill_no from save;";


106
St.Raphael’s H.S. School
stmt= con.createStatement();

rs = stmt.executeQuery(sql1);

rs.last();

rs.previous();

if(rs.next())

count=rs.getInt(1);

count++;

jTextField2.setText(""+count);

else

jTextField2.setText(""+count);

catch(Exception e)

{JOptionPane.showMessageDialog(null,e.getMessage());}

SAVE:-
try{

107
St.Raphael’s H.S. School
int rows=jTable1.getRowCount();

boolean flag=false;

for(int row=0;row<rows;row++)

int billno= Integer.parseInt(jTextField2.getText());

String name= jTextField3.getText();

String add= jTextField4.getText();

String phno= jTextField5.getText();

String pname=(""+jTable1.getValueAt(row,0));

int price=Integer.valueOf(""+jTable1.getValueAt(row,1));

int totalprice=Integer.parseInt(jTextField7.getText());

Class.forName("java.sql.Driver");

Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/pizzahut","root","
tiger");

String sql="insert into save values('"+ billno + "', '"+name + "' , '" + add +
"' , '"+ phno +"','"+ pname + "', "+price + " , " + totalprice + ");";

Statement stmt=con.createStatement();

stmt.executeUpdate(sql);

flag=true;

if(flag==true)

108
St.Raphael’s H.S. School
{

JOptionPane.showMessageDialog(null,"RECORD SAVED");

String sql1="delete from order1;";

stmt.executeUpdate(sql1);

members_login m=new members_login();

this.setVisible(false);

m.setVisible(true);

catch(Exception e)

JOptionPane.showMessageDialog(null,e);

109
St.Raphael’s H.S. School

110

You might also like