You are on page 1of 40

NAME - NISHANT SINHA

CLASS - 12TH

SECTION - SCIENCE

SUBJECT – INFORMATICS PRACTICES

PRACTICAL FILE FOR THE YEAR 2019-20

SCHOOL NAME – SHREE


SWAMINARAYAN GURUKUL, CHALA
ACKNOWLEDGEMENT
I would like to express my special thanks of
gratitude to my informatics practices teacher
Mrs.Gayatri Ghadiali as well as our principal Sir
Ajit Hukerikar who gave me the golden
opportunity to do this wonderful project on the
topic , which also helped me in doing a lot of
Research and i came to know about so many new
things I am really thankful to them.
Secondly i would also like to thank my parents
and friends who helped me with the project.
INDEX
SR.NO TOPIC SIGNATURE

1. Network Configuration and Open Source


Software
2. To find larger number and to check valid grade

3. Simple Interest Calculator

4. Fibonacci series

5. Printing Patterns

6. To find LCM of given two numbers

7. Program to calculate Net Amount

8. Program to calculate bill for Mega mall

9. Program to calculate sum of input digit

10. Program to check if the input string is


Palindrome or not
11. Program to convert input String to Sentence
case
12. Program to calculate vowels in the input
strings
13. Program to print even numbers series in a list
box
14. Program of connectivity to add, load, delete,
and Update record in Library Table

15. Program to display records with matching


criteria
16. SQL Queries( 24 Questions)

17. Webpage-1

18. Webpage -2
NETWORK CONFIGURATION AND OPEN SOURCE SOFTWARE
NETWORK CONFIGURATION

Our school lab is well equipped and has 42 personal computers. The
configuration of each computer is as follows:
 Intel Pentium processor @2.9GHz
 RAM 4GB
 Hard Disk 500GB
 USB Keyboard Interface
 USB Optical Mouse
 Network Card
 32-bit Windows Operating System
LAN Network is configured using twisted pair cables in the lab. For better
performance a simple installation of Point to Point(P_P) link between each
computers is in the network. Two switches are used to segment networks into
different sub-networks or LAN segments.

Open Source Software


The various Open source software on each computer are:

 Netbeans IDE 6.5.1


 Mysql 5.1
 OpenOffice 3.4.1
 Python 3.7
Q1. Design a GUI Application having interface shown below

 In the left half of the interface, two numbers are to be accepted. When
the user clicks on greater button, greater number with appropriate
message should be displayed.
 In the right half of the above interface, a number grade is input. Valid
grades are 0-4. Upon clicking check validity button, a message depicting
validity of the grade should be displayed.
Source Code:
For (Greater) Button
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int a= Integer.parseInt(jTextField1.getText());
int b=Integer.parseInt(jTextField2.getText());
if (a>b){
jLabel4.setText(" Greater number is" + a); }
else if(b>a) jLabel4.setText(" Greater number is" + b);
For Check validity Button:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
int c=Integer.parseInt(jTextField3.getText());
if(c>=0&&c<=4){
jLabel5.setText("The grade is valid");
}
else
jLabel5.setText("The grade is invalid"); }
OUTPUT
Q.2. Mr Rehaan frequently need to calculate interest and amount due to his
clients. He asked his software programmer to design a calculator which will
calculate the simple interest and amount due if he takes loan for 5, 10, 15
years.

SOURCE CODE:

For calculate button:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

int pa=Integer.parseInt(jTextField1.getText());

double r= Double.parseDouble(jTextField2.getText());

double i,a;
int t=0;
if (jRadioButton1.isSelected()){
t=5; }
else if(jRadioButton2.isSelected()){
t=10; }
else if(jRadioButton3.isSelected()){
t=15; }
i=pa*r*t/100;
jTextField3.setText(""+i);
a=i+pa;
jTextField4.setText(""+a);}
For Clear Button:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
jTextField4.setText("");
jRadioButton1.setSelected(false);
jRadioButton2.setSelected(false);
jRadioButton3.setSelected(false); }
For exit button:
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);

OUTPUT
Q.3. Write a program to print 20 terms of Fibonacci Series in output window.
1 1 2 3 5 8...............

SOURCE CODE:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int a=1; int b=1;
int sum;
System.out.print(" "+ a);
System.out.print(" "+b);
for(int i=1; i<=18; i++){
sum=a+b;
System.out.print(" "+sum);
a=b;
b=sum;}

OUTPUT WINDOW:
Q.4. Design an application using nested loop to print the given patterns. Use
button pattern 1 to display first patterns and pattern2 button to display
pattern in an output area.

4 a

43 ab

432 abc

4321 abcd

SOURCE CODE FOR PATTERN1:


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
for(int i=4; i>=1; i--){
for(int j= 4; j>=i; j--)
System.out.print( " "+j);
System.out.println();}}
Output:
SOURCE CODE FOR PATTERN 2
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
char i,j;
for(i='a'; i<='d'; i++){
for(j='a'; j<=i; j++)
System.out.print(" "+j);}}
System.out.println();}}
Q.5. Write a java code to find the LCM of the input 2 number’s. And print it in
label.

SOURCE CODE:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt{
int n1= Integer.parseInt(jTextField1.getText());
int n2 = Integer.parseInt(jTextField2.getText());
int t, x, y, lcm;
x=n1;
y=n2;
while(n2!=0){
t=n2;
n2=n1%t;
n1=t;}
lcm= x*y/n1;
jLabel4.setText(" "+lcm); }

OUTPUT:
Q6. Mr. Ram Kishore, owner of the Kiddi Land Enterprises has asked his
programmer Saumya to develop the following GUI in Netbeans.
Mr. Ram accepts payment through three types of credit cards. The offer is
given according to the following schemes:
TYPE OF CARDS OFFER
PLATINUM 20% OF DISCOUNT
GOLD 15% OF DISCOUNT
SILVER 10% OF DISCOUNT

If the Bill Amount is more than Rs. 25000 then the customer gets an additional
offer of 5%.
Write the java code for the following:
1) To assign Additional Offer as 0 and Net Amount as 0. Also set them as
uneditable.
2) When Calculate Button is clicked calculate discount as per the given
criteria and display the same in Textfield3.
3) When calculate Net Amount is clicked calculate Net Amount(total cost –
offer- Additional offer) and display it in jTextField5.

SOURCE CODE:
For calculate discount button:
double dis=0, dis1, dis2=0,amt;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
double amt = Double.parseDouble(jTextField2.getText());
if(jRadioButton1.isSelected()==true)
dis=20;
else if(jRadioButton2.isSelected()==true)
dis=15;
else if(jRadioButton3.isSelected()==true)
dis=10;
dis1= amt*dis/100;
if(amt>25000)
dis2= amt*5/100;
jTextField3.setText(" "+dis1);
jTextField4.setText(" "+dis2);}
jTextField4.setEditable(false);
jTextField5.setEditable(false);}

For Calculate Net Amount Button:


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
double netamt= amt-dis1-dis2;
jTextField5.setText(" "+netamt);

For exit button:


private void jButton3ActionPerformed(java.awt.event.ActionEvent evt {
System.exit(0); }

Output:
Q.7. Write a GUI application to calculate bill for mega mall.

(a) Write the code for the calculate button to display the discount and final
price in the Discount and Final Price Textfield respectively. Note that the
final price is calculated as (price-discount) and the discount is calculated
based on the category and price according to the following table. If Card
Holder is selected 5% discount to be given.
Category Price Discount
Men’s <10000 30%
>=10000 50%
Women’s <8000 40%
>=8000 50%
Kid’s <5000 20%
>=5000 30%

(b) Write the code for the TestData button to ensure that the user does not
enter a negative or a zero value in a price TextField. If a negative or a
zero value is entered then price textfield should be made blank and a
warning message should be displayed in a JOptionPane.
(c) Write the code for the clear button to clear all RadioButtons and final
price textfield and card holder checkbox.
(d) Write the code for Exit Button to exit the application but before closing
the application it should display message “Have a nice day”.

import javax.swing.JOptionPane;
GENERATED CODE
double disc, finalp, disc1, discount, disc2 =0;
SOURCE CODE:
For TestData Button:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
double n= Double.parseDouble(jTextField3.getText());
if(n<=0){
jTextField3.setText("");

JOptionPane.showMessageDialog(null, "Entered value is negative");


}
else
JOptionPane.showMessageDialog(null, " Entered Value is correct
you can continue");

For Calculate Button:


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt){
int n1 = Integer.parseInt(jTextField1.getText());
String item = jTextField2.getText();
double p=Double.parseDouble(jTextField3.getText());
if(jRadioButton1.isSelected()==true){
if(p<10000)
disc=0.30;
else if(p>=10000)
disc=0.50;
}
disc1=p*disc;
if(jCheckBox1.isSelected()==true)
disc2=p*0.05;
else
disc2=0;
discount= disc1+disc2;
finalp= p-discount;
if(jRadioButton2.isSelected()==true){
if(p<8000)
disc=0.40;
else if(p>=10000)
disc=0.50;}
disc1=p*disc;
if(jCheckBox1.isSelected()==true)
disc2=p*0.05;
else
disc2=0;
discount= disc1+disc2;
finalp= p-discount;
if(jRadioButton3.isSelected()==true){
if(p<5000)
disc=0.20;
else if(p>=5000)
disc=0.30;
}
disc1=p*disc;
if(jCheckBox1.isSelected()==true)
disc2=p*0.05;
else
disc2=0;
discount= disc1+disc2;
finalp= p-discount;
jTextField4.setText(" "+discount);
jTextField5.setText(" "+finalp);}
For Clear Button:
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField5.setText("");
jRadioButton1.setSelected(false);
jRadioButton2.setSelected(false);
jRadioButton3.setSelected(false);
jCheckBox1.setSelected(false);
For Exit button:
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
JOptionPane.showMessageDialog(null, "HAVE A NICE DAY");
System.exit(0);

OUTPUT:
Q.8. Create an application that receives a number through textfield and prints
the sum of its individual digits when submit button is pressed as shown below.

SOURCE CODE:
For submit button:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
int b=0, rev=0, sum=0;
int n1= Integer.parseInt(jTextField1.getText());
while(n1!=0){
b=n1%10;
sum=sum+b;
rev= rev*10+b;
n1=n1/10;
} jTextField2.setText(" "+sum);

OUTPUT
Q.9. Design an application to check whether the string is a Palindrome or not.

SOURCE CODE
For check button
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String str=jTextField1.getText();
StringBuffer str1= new StringBuffer(str);
str1= str1.reverse();
String str2=new String(str1);
if(str2.equals(str))
jLabel2.setText("It is a Palindrome ");
else
jLabel2.setText("It is not a Palindrome");
}

OUTPUT
Q.10. Design an application to convert input string to Sentence Case.

SOURCE CODE:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String s1= jTextField1.getText();
int len= s1.length();
char ch = Character.toUpperCase(s1.charAt(0));
s1= ch+ s1.substring(1);
for(int i=0; i<=s1.length()-1; i++){
if(s1.charAt(i)== ' '){
ch= Character.toUpperCase(s1.charAt(i+1));
s1= s1.substring(0, i+1) + ch+ s1.substring(i+2)
}
} jTextField1.setText(s1); }

OUTPUT
Q.11. Design an application to count total number of Vowels in the input
String.

SOURCE CODE:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int count=0;
String s= jTextField1.getText();
for(int i=0; i<s.length(); i++){
char ch= s.charAt(i);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){
count=count+1; }
jLabel2.setText(" "+count);
}}
OUTPUT
Q.12.Design a Java application to print Even no. series from the range 1 to 100
as an item in List Box.

SOURCE CODE:
import javax.swing.DefaultListModel;
For Print Series Button:
nprivate void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
DefaultListModel m= new DefaultListModel();
for (int i=2; i<=100; i=i+2){
m.addElement(i);
jList1.setModel(m);} }

OUTPUT
Q.13. Create a table ‘Library’ having following structure :
Column name Data Type Size Constraint
Libno Int 4 Primary Key
Title Varchar 20 Not null
Author Varchar 25
Publisher Varchar 30
Price Int 7
Purchasedate Date

i) Design a connectivity application to add, load, delete and update the


records in the Library table.
ii) Clear Button clear the TextFields.
iii) Exit button to close the application.
SOURCE CODE:
import java.sql.*;
import javax.swing.JOptionPane;
For Load Button :
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
try{
Class.forName("java.sql.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/Nishant", "root",
"admin");
Statement stmt= con.createStatement();
String q= "Select * from Library where
Libno='"+jTextField1.getText()+"';";
ResultSet rs= stmt.executeQuery(q);
if(rs.next()){
String titl= rs.getString("Title");
String aut= rs.getString("Author");
String pub= rs.getString("Publisher");
int pr= rs.getInt("Price");
String da= rs.getString("Purchasedate");
jTextField2.setText(titl);
jTextField3.setText(aut);
jTextField4.setText(pub);
jTextField5.setText(""+pr);
jTextField6.setText(da);

}
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
For Delete Buttton:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt){
try{
Class.forName("java.sql.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/Nishant", "root",
"admin");
Statement stmt= con.createStatement();
String q= "Delete from Library where Libno='"+jTextField1.getText()+"';";
stmt.executeUpdate(q);
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);}
}
For Clear Button:
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(" ");
jTextField2.setText(" ");
jTextField3.setText(" ");
jTextField4.setText(" ");
jTextField5.setText(" ");
jTextField6.setText(" ");}

For Exit Button:


private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
For Add Button:
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
try{
int lib= Integer.parseInt(jTextField1.getText());
String tit= jTextField2.getText();
String au= jTextField3.getText();
String pub= jTextField4.getText();
int pr= Integer.parseInt(jTextField5.getText());
String da= jTextField6.getText();
Class.forName("java.sql.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/NIshant", "root",
"admin");
Statement stmt= con.createStatement();
String q= "insert into Library values('"+lib+"', '"+tit+"', '"+au+"',
'"+pub+"', '"+pr+"', '"+da+"');";
stmt.executeUpdate(q);
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
For Update Button:
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
try{
int lib=Integer.parseInt(jTextField1.getText());
int pr= Integer.parseInt(jTextField5.getText());
Class.forName("java.sql.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/Nishant", "root",
"admin");
Statement stmt= con.createStatement();
String q= "Update Library set Title='"+jTextField2.getText()+", Author
='"+jTextField3.getText()+"', Publisher='"+jTextField4.getText()+"',Price =
"+pr+", Purchasedate='"+jTextField6.getText()+"' where Libno= '"+lib+"';";
stmt.executeUpdate(q);

}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);}}
OUTPUT FOR LOAD BUTTON:
Q.14. Design a Java application to retrieve the data from a “Course “ table for
the given coursed in a Table control by clicking on Retrieve button. By clicking
on clear button the Table should get clear.
RNo Name Class Course ID Coursename
1 Ankit X C001 IT
2 Shreya XI C002 Commerce
3 Palak XI C003 Math/Bio
4 Neel VIII C004 IT
5 Preksha IX C005 IT

SOURCE CODE:
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
For Retrieve Button:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel model= (DefaultTableModel) jTable1.getModel();
try{
Class.forName("java.sql.Driver");
Connection con
=DriverManager.getConnection("jdbc:mysql://localhost/Nishant", "root",
"admin");
Statement stmt= con.createStatement();
String q= "select* from Course;";
ResultSet rs= stmt.executeQuery(q);
while(rs.next()){
int rno= rs.getInt("rno");
String na= rs.getString("Name");
String cla= rs.getString("Class");
String couid= rs.getString("CourseID");
String cou= rs.getString("Coursename");
model.addRow(new Object[]{ rno, na, cla, couid, cou});
}
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
OUTPUT:
15. Consider the following table SHOP and answer the following questions:
No. Shopname Sales Area Cust_percent Rating City
1 S.M. Sons 250000 West 68.6 C Delhi
2 Dhirajner 500000 South 81.8 A Mumbai
3 Kirtit 300000 North 79.8 B Kolkata
4 Scant Ripple 380000 North 88.0 NULL Mumbai
5 Biswas 456000 East 92.0 A Delhi
Store
6 Crystal 290000 South 66.7 A Kolkata

Write MySQL commands for the following statements:


1. To display the names of all shops which are in south area.

2. To display and customer percent of all the shops whose


cust_percent>80.

3. To display list of all shops with sales more than 300000 in ascending
order of shopname.

4. To display a report with Shopname, area, and rating for each shop in the
table for only those shops whose sales is between 350000 and 400000.
5. To display the city and the number of shops in each city.

6. To Add Primary Key constraint on the appropriate field.

7. To display average sales of shops whose city is Delhi.

8. To display total sale from shop whose rating is A.

9. Give the output of the following queries.


i)Select Min(cust_percent) from shop;

10.To display the details of the shop whose rating is null.


11.To display shopname from shop whose cityname ends with letter ‘i’.

12.To display report showing shopname, area, city, and sales/12 as ‘Monthy
sales’ from shop table.

13.To change the city name to ‘bombay’ whose city is Mumbai.

14.To add a new column ownername to shop table.

15.To delete a record from shop whose shopname is Kirtit.

16.To change the column name sales to ‘yearlysales’.


Create the given table and write the SQL command for the following.
Table: Staff
ID Name Dept Sex Experiance
101 Siddharth Sales M 12
104 Ravi Finance M 5
107 Naman Research M 10
114 Nupur Sales F 3
109 Janvi Finance F 9
105 Rama Research M 10

Table Salary:

ID Basic Allowance Commission


101 12000 1000 3
104 23000 2300 5
107 32000 4000 5
114 42000 5200 10
109 18900 1690 3
130 21700 2600 30

17.Identify a foreign key field and write command to apply foreign key
field.

18.To count name of all staff that are in sales having more than 10 years of
experience.
19.To display the highest commission(%) among all male staff.

20.Display average salary of all staff working in finance department where


salary =Basic+Allowance.

21.To display name, count(dept), basic from salary and staff for their
corresponding ID.

22. Create a natural join between staff and salary table using join clause.
23. Create an Equijoin between Staff and Salary table.

24. Delete a Foreign key constraint from salary table.

17. 1) Write the HTML code to generate the following webpage with the given
below specifications:
(a) Title of the webpage is “ecommerce”.
(b) Heading of the page is in centre and in maroon colour.
(c) Caption of table is blue colour.
(d) Background of table is “cyan” colour and border of size 2.
(e) List heading is red in centre.
(f) Create a bulleted list and underline all list item.

<html>
<head>
<title>Ecommerce</title>
</head>
<body>
<h1 align='center'><font color='maroon'> eCommerce</font></h1>
<img src="C:\Intel\COMP.PNG" align='right'>
<p align='center'> Ecommerce or electronic commerce is a subset of ebusiness,
e-commerce
is the purchasing, and exchanging of goods<br>
and services over computer networks(such as internet) through which
transactions or terms
of sale are performed electronically.
</p>
<br>
<br>
<table bgcolor= 'cyan' align ='center' border=2>
<font color='blue'><caption><h3><font color='blue'>eCommerce
requirements</h3></font></caption>
<tr align='center'><td>Shopping cart</td><td>Merchant account</td></tr>
<tr align='center'><td>Processing gateway</td><td>Digital
Certificate</td></tr>
</table>
</br>
<h3 align='left'><font color='red'> Ecommerce can be broken into four
categories</font></h3>
<ul type='disc'>
<li><u>B2B(Business-to-Business)</u></li>
<li><u>B2C(Business-to-Consumer)</u></li>
<li><u>C2B(Consumer-to-Business)</u></li>
<li><u>C2C(Consumer-to-Consumer)</u></li>
</ul>
</body>
</html>
2) Write an XML document to represent the following recipe as shown:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>


<?xml-stylesheet href="recipe.css" type="text/css"?>
<recipe>
<head>
<title>Chutney Recipe</title>
</head>
<ing>
<in>
<amt><qty>2</qty>
<unit>bunches</unit>
</amt><itname>fresh coriander</itname>
</in>
<in>
<amt><qty>1</qty>
<unit> </unit>
</amt><itname>tart green apple</itname>
</in>
<in>
<amt><qty>2</qty>
<unit> </unit>
</amt><itname>Tomatoes</itname>
</in>
<in>
<amt><qty>2</qty>
<unit> </unit>
</amt><itname>fresh pepper</itname>
</in>
<in>
<amt><qty>1</qty>
<unit>teaspoon </unit>
</amt><itname>salt and sugar</itname>
</in>
</ing>
<procedure>
<step> 1. Was the fresh coriander thoroughly. </step>
<step> 2. Peel and chop the apple in small pieces. </step>
<step> 3. Cut each tomatoe into four pieces. </step>
<step> 4. Combine all the ingredients. </step>
<step> 5. Blend untill a fine paste. </step>
</procedure>
</recipe>

recipe{display:block}
title {font-size:large; font-weight:bold; text-align:center; display:block;
color:#800000;}
ing {display:block; margin-top:20px; text-align:center; margin-left:10pt; font-
family:verdana;}
in {display:block; margin-left:60pt; text-align:left;}
amt{font style:itallic;}
procedure {display:block; margin-top18px; margin-left:60pt; text-align:left;}
step {display:block; font-color:blue; margin-top:10pt; font-family:Arial; margin-
left:60pt; text-align:left;}

You might also like