< ;
Breaking News
Loading...

Tuesday, September 10, 2019

Informatics Practices class 12 PRACTICAL FILE WITH PDF

Informatics Practices class 12 PRACTICAL FILE WITH PDF


Informatics Practices class 12 PRACTICAL FILE WITH PDF.HERE THIS PRACTICAL FILE HELP YOU TO SAVE YOUR TIME , AND BRAIN
PRACTICAL FILE NECCESSARY TO MAINTAIN FOR CLASS XII STUDENTS

YOU CAN SIMPLY DOWNLOAD THIS FILE IN PDF FORMAT BY CLICK ON DOWNLOAD BUTTON

Related image
-----------------------------------------------------------------------------------------------------------------------



                                                PRACTICAL QUESTION 1
QUESTION:  MR.ram kishore, the owner of the kiddi land enterprises has asked his programmer samya 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 scheme:
TYPES OF CARD OFFER
offer
Platinum
20% of amount
Gold
15% of amount
Silver
10% of amount

If the bill amount is more than rs25,000/- then the customer gets an additional offer of 5%


Answer:  CALCULATE DISCOUNT BUTTON CODING:
· jtf4.setText("0");
 jtf5.setText("0");
 jtf4.setEditable(false);
 jtf5.setEditable(false);
 double dis=0;
 double amt=Double.parseDouble(jtf2.getText());
 if(platrb.isSelected()==true)
 dis=amt*0.20;
 else if(silvrb.isSelected()==true)
 dis=amt*0.10;
 else dis=amt*0.15;
 jtf3.setText(""+dis);
 double add = 0;
 if(amt>25000) add=amt*0.05;
 jtf4.setText(""+add);
 golrb.setEnabled(true); 
CALCULATE NET AMOUNT BUTTON CODING:
· double totalcost=Double.parseDouble(jtf2.getText());
 double offer=Double.parseDouble(jtf3.getText());
 double additionaloffer=Double.parseDouble(jtf4.getText());
double netamount=totalcost-offer-additionaloffer;
 jtf5.setText(""+netamount);
  EXIT BUTTON CODING:
· System.exit(0);






           PRACTICAL QUESTION 2
QUESTION: Semma is a junior programmer at ‘AVON SHOE FACTORY’ . she has created a GUI in netbeans.


3 items namely shoes, sandals and slippers are
· manufactured by the factory.  A buyer can buy more than one item at a time
.·  Each pair of shoes cost rs. 1500/- each pair of
· sandals costs rs. 500/- .  The item bought will be selected by the user and
· the quantity bought will be entered by the user.  Amount to be for that item will be displayed in
· front of the item.

  CALCULATE BUTTON CODING:Ø
int qty1, qty2, qty3 ;
 double amt1 = 0.0, amt2 = 0.0, amt3 = 0.0,tamt=0.0;
 if(shoecb.isSelected())
 {
qty1 = Integer.parseInt(jtf1.getText());
 amt1=qty1*1500;
 jtf2.setText(Double.toString(amt1));
 }
 if(sandalcb.isSelected())
 {
qty2=Integer.parseInt(jtf3.getText());
 amt2=qty2*1000; jtf4.setText(Double.toString(amt2));
 }
 if(slipperscb.isSelected())
 {
qty3=Integer.parseInt(jtf5.getText());
amt3=qty3*500;
 jtf6.setText(Double.toString(amt3));
 }
 tamt=amt1+amt2+amt3;
 jtf7.setText(Double.toString(tamt));
 CLEAR BUTTON CODING:Ø
 jtf1.setText(" ");
 jtf2.setText(" ");
 jtf3.setText(" ");
 jtf4.setText(" ");
 jtf5.setText(" ");
 jtf6.setText(" ");
 jtf7.setText(" ");
shoecb.setSelected(false);
 sandalcb.setSelected(false);
 slipperscb.setSelected(false);
  EXIT BUTTON CODING:Ø
 System.exit(0);
                                                                                           OUTPUT:




PRACTICAL QUESTION 3
QUESTION: Ms Sharma works as a programmer in ‘ABC CAR RENTAL COMPANY’ where she has designed a software to compute charges to be paid by the client . a screenshot of the same is shown here.

 A client can take any car out of deluxe/semi
deluxe/ordinary for rent.
 A client can also opt for services of a guide. Charges vary
depending on the type of car opted.
 Charges of services of guide are extra.
 Help ms . Sharma in writing the code to do the following:
Ans-
 CALCULATE BUTTON CODING:
int nodays, amt=0, guidecharges=0,
totalamt=0;
nodays=Integer.parseInt(tbdays.getText());
if(rbdeluxe.isSelected())
amt=1000*nodays;
else if(rbsemi.isSelected())
amt=800*nodays;
else if(rbord.isSelected())
amt=700*nodays;
tbamt.setText(""+amt);
if(cbguide.isSelected())
guidecharges=500*nodays;
tbguide.setText(""+guidecharges);

totalamt=amt+guidecharges;
tbtotal.setText(""+totalamt);// TODO add
your handling code here:
}

 CLEAR BUTTON CODING:
tbname.setText("");
tbphone.setText("");
tbdays.setText("");
tbamt.setText("");
tbguide.setText("");
tbtotal.setText("");
cbguide.setSelected(false);
 EXIT BUTTON CODING:
System.exit(0);

                                                  OUTPUT:



                        PRACTICAL QUESTION 5
QUESTION: The students of “SHIKSHA VIDALYA” work for different extra circular activities like ‘community outreach programme’
,‘swachh bharat abhiyan’ and ‘traffic safety club’ . the programme at
the school has developed a GUI application as shown below:
 A student can participate in more than one activities.
 Each students gets 1 point for each activity.
Help the programmer to write code for the following:

ANS-
CALCULATE TOTAL SCORE BUTTON CODING:

{
if(trafficcb.isSelected())

traffictf.setText("10");
else traffictf.setText("0");
}
{if(bharatcb.isSelected())
bharattf.setText("10");
else bharattf.setText("0");
}
{if(commcb.isSelected())
commtf.setText("10");
}
int x = Integer.parseInt(commtf.getText());
int y = Integer.parseInt(bharattf.getText());
int z = Integer.parseInt(traffictf.getText());
int a = x+y+z;
totaltf.setText(""+a);

 CLEAR BUTTON CODING:
nametf.setText("");
rolltf.setText("");
commtf.setText("");
bharattf.setText("");

traffictf.setText("");
totaltf.setText("");
trafficcb.setSelected(false);
bharatcb.setSelected(false);
commcb.setSelected(false);

 EXIT BUTTON CODING:
System.exit(0);





Output:


   PRACTICAL QUESTION 6
QUESTION: MR. rangaswami works at a recreation park as a system
Analyst the following GUI.
When a group arrives at recreation park, the number of people in the group and whether the group wants to enjoy the waterpark or not is entered . entry fees is rs 500/- per person. The person can choose to play at waterpark by selecting the checkbox. Rides of waterpark will cost rs250/- extra per person. Help him to write code for the following.
ANS-

 CALCULATE BUTTON CODING:
if(watercb.isSelected())
parktf.setText("250");

else parktf.setText("0");
int a = Integer.parseInt(peopletf.getText());
int b = a*500;
feestf.setText(""+b);
int c = Integer.parseInt(parktf.getText());
int e = c*a;
parktf.setText(""+e);
int d = b+e;
totaltf.setText(""+d);
 CLEAR BUTTON CODING:
peopletf.setText("");
feestf.setText("");
parktf.setText("");
totaltf.setText("");
watercb.setSelected(false);
 EXIT BUTTON CODING:
System.exit(0);

                   Output:




    PRACTICAL QUESTION 9
QUESTION: Design a GUI application that has a list and a
few controls such as a label , a button and a text field . the list
display some color . when a user select a color from the list ,
the background of the appropriate control should be changed.
ANSWER:
 ON THE TOP:
import java.awt.Color;
 LIST BOX CODING:
int i;

Color x=Color.WHITE;
i =colorslst.getSelectedIndex();
switch(i){
case 0: x=Color.RED;break;
case 1: x=Color.BLUE;break;
case 2: x=Color.GREEN;break;
case 3: x=Color.MAGENTA;break;
case 4: x=Color.CYAN;break;
case 5: x=Color.YELLOW;break;
case 6: x=Color.GRAY;break;
}
if(lblchk.isSelected())
lbl.setBackground(x);
else
lbl.setBackground(Color.WHITE);
if(btnchk.isSelected())
btn.setBackground(x);
else
btn.setBackground(Color.WHITE);
if(tfchk.isSelected())
tf.setBackground(x);
else

tf.setBackground(Color.WHITE);
 LABEL CHECKBOX CODING:
int i;
Color x=Color.WHITE;
i =colorslst.getSelectedIndex();
switch(i){
case 0: x=Color.RED;break;
case 1: x=Color.BLUE;break;
case 2: x=Color.GREEN;break;
case 3: x=Color.MAGENTA;break;
case 4: x=Color.CYAN;break;
case 5: x=Color.YELLOW;break;
case 6: x=Color.GRAY;break;
}
if(lblchk.isSelected())
lbl.setBackground(x);
else
lbl.setBackground(Color.WHITE);
if(btnchk.isSelected())
btn.setBackground(x);
else
btn.setBackground(Color.WHITE);

if(tfchk.isSelected())
tf.setBackground(x);
else
tf.setBackground(Color.WHITE);
 BUTTON CHECKBOX CODING:
int i;
Color x=Color.WHITE;
i =colorslst.getSelectedIndex();
switch(i){
case 0: x=Color.RED;break;
case 1: x=Color.BLUE;break;
case 2: x=Color.GREEN;break;
case 3: x=Color.MAGENTA;break;
case 4: x=Color.CYAN;break;
case 5: x=Color.YELLOW;break;
case 6: x=Color.GRAY;break;
}
if(lblchk.isSelected())
lbl.setBackground(x);
else
lbl.setBackground(Color.WHITE);
if(btnchk.isSelected())
btn.setBackground(x);
else
btn.setBackground(Color.WHITE);
if(tfchk.isSelected())
tf.setBackground(x);
else
tf.setBackground(Color.WHITE);
 TEXTFIELD BUTTON CODING:
int i;
Color x=Color.WHITE;
i =colorslst.getSelectedIndex();
switch(i){
case 0: x=Color.RED;break;
case 1: x=Color.BLUE;break;
case 2: x=Color.GREEN;break;
case 3: x=Color.MAGENTA;break;
case 4: x=Color.CYAN;break;
case 5: x=Color.YELLOW;break;
case 6: x=Color.GRAY;break;
}
if(lblchk.isSelected())
lbl.setBackground(x);
else
lbl.setBackground(Color.WHITE);
if(btnchk.isSelected())
btn.setBackground(x);
else
btn.setBackground(Color.WHITE);
if(tfchk.isSelected())
tf.setBackground(x);
else
tf.setBackground(Color.WHITE);






           

CONNECTIVITY PROGRAM
Create a table named contact with name, mobile no. , email as its columns.


Answer1: On the top of the source editor
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

On the click of add button
String name = jtf1.getText();
String mobile = jtf2.getText ();
String email = jtf3.getText();
try { Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse",
"root","shagun");
Statement stmt = con.createStatement();
String query = "Insert into contact values('"+name+"', '"+mobile+"',
'"+email+"');";
stmt.executeUpdate(query);
} catch(Exception e)
{JOptionPane.showMessageDialog(this, e.getMessage());
}
On the click of exit button
System.exit(0);
In mysql (coding)
Create database cbse;
Use cbse;
Create table contact(name varchar(20),
Mobile varchar(10),Email varchar(20));

OUTPUT,.......
                                   PROGRAM 2
Question: On the basis of the following GUI.
The information related to the customer should be passed to the table
customer. If the user pays through cash 10% discount and credit card
15% discount.
Answer: On the top of the source
import java.sql.*;
import javax.swing.JOptionPane;
On the click of calculate button
double disc=0, amt;
String name = jtf1.getText();
String bill = jtf2.getText();
float x =Float.parseFloat(bill);

if(jrb1.isSelected()) disc = x*(0.10);
if(jrb2.isSelected()) disc = x*(0.15);
jtf3.setText("" + disc);
amt = x-disc;
jtf4.setText("" + amt);
On the click of add button
String name=jtf1.getText();
String bill =jtf2.getText();
String discount=jtf3.getText();
String netamt=jtf4.getText();
try{Class.forName("java.sql.DriverManager");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/cbs
e","root","shagun");
Statement stmt = con.createStatement();
String query="Insert into customer
values('"+name+"','"+bill+"','"+discount+"','"+netamt+"');";
stmt.executeUpdate(query);
}catch(Exception e)
{JOptionPane.showMessageDialog(this,e.getMessage());
On the click of clear button
jtf1.setText(" ");
jtf2.setText(" ");
jtf3.setText(" ");
jtf4.setText(" ");
On the click of exit button
System.exit(0);

OUTPUT.......


      
 

         PROGRAM – 3
Question: Create a GUI as shown below:
On the click of search button on the basis of mobile no. entered respective name and email id should be searched .Create the table contact and insert few values into it

Ans: create database cbse;
Use cbse;
Create table contact(name varchar(20), mobile varchar(10), email
varchar(20));
Insert into contact values (‘ash’,8512099964,’ash123@gmail.com’);
Insert into contact values
(‘shagun’,7982032861,’shagun@gmail.com’);
• ON THE TOP
import java.sql.*;
import javax.swing.JOptionPane;
• ON THE CLICK OF SEARCH BUTTON
String mobile = jtf2.getText();
if(mobile.isEmpty())
{jtf1.setText(" ");
jtf3.setText(" ");
JOptionPane.showMessageDialog(this,"enter valid mobile no");
}
else{
try{Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","r
oot","shagun");
Statement stmt = con.createStatement();
String query = "select name, email from contact where mobile =
'"+mobile+"';";
ResultSet rs = stmt.executeQuery(query);

if(rs.next())
{String name = rs.getString("name");
String email = rs.getString("email");
jtf1.setText(" " +name);
jtf3.setText(" "+email);
}
}
catch(Exception e)
{JOptionPane.showMessageDialog(this,e.getMessage());
}
}
• CLICK ON EXIT BUTTON
System.exit(0);

OUTPUT:


              PROGRAM-4
Question: Create a GUI as shown below:
create table official with three columns name, email, mobileno. Insert a few rows in it.
answer:
 sql code:
create table official (name varchar(20),mobile varchar(10),email
varchar(30));
Insert into official values(‘shagun’,7982032861,’shagungiri@gmail.com’);
Insert into official values(‘isha’,8512099964,’isha@gmail.com’);
Insert into official values(‘vikram’,8377065120,’vikram@gmail.com’);
 ON THE TOP:

import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
 REFRESH BUTTON CODING:

DefaultTableModel y =(DefaultTableModel) jtable1.getModel();
try{Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root",
"shagun");

Statement stmt = con.createStatement();
String x = "Select * from official";
ResultSet rs = stmt.executeQuery(x);
while(rs.next())
{String name = rs.getString("name");
String mobile = rs.getString("mobile");
String email = rs.getString("email");
y.addRow(new Object[]{name,mobile,email});
}
}
catch(Exception e)
{JOptionPane.showMessageDialog(this,e.getMessage());
}

 RESET BUTTON CODING:

DefaultTableModel x =(DefaultTableModel) jtable1.getModel();
int rows= x.getRowCount();
if(rows>0)
{for(int i=0; i<rows; i++)
x.removeRow(0);
 EXIT BUTTON CODING:
System.exit(0);

OUTPUT:
              PROGRAM 5
QUESTION: create a GUI that perform update and delete operation on a database .
Create a table department with departmentnono, departmentname,
location.
Insert a few rows into it.
ANSWER :
 SQL CODE:
Create table dept (deptno varchar(30), deptname varchar(30),
location varchar(30));
Insert into dept values(10,’accounting’,’new delhi’);
Insert into dept values(12,’research’,’chennai’);
Insert into dept values(13,’sales’,’kolkata’);

 ON THE TOP:
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
 SEARCH BUTTON CODING:
String deptno = jtf1.getText();
if(deptno.isEmpty())
{jtf2.setText(" ");
jtf3.setText(" ");
JOptionPane.showMessageDialog(this,"enter valid mobile no");
}
else{
try{Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","r
oot","shagun");
Statement stmt = con.createStatement();
String query = "select * from dept where deptno = '"+deptno+"';";

ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{String deptname = rs.getString("deptname");
String location = rs.getString("location");
jtf2.setText(" " +deptname);
jtf3.setText(" "+location);
}
}
catch(Exception e)
{JOptionPane.showMessageDialog(this,e.getMessage());
}
 UPDATE BUTTON CODING:
int ans = JOptionPane.showConfirmDialog(null,"surely wanna update
the record?");
if(ans == JOptionPane.YES_OPTION){
try {Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","r
oot","shagun");
Statement stmt = con.createStatement();

String query = "UPDATE dept SET deptname = '"+jtf2.getText()+"',
location = '"+jtf3.getText()+"' WHERE deptno ="+jtf1.getText()+";";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null,"record successfully
updated.");
}
catch(Exception e ){
JOptionPane.showMessageDialog(null,"error in table updation!");
}
 DELETE BUTTON CODING:
int res = JOptionPane.showConfirmDialog(null,"Wanna delete the
record for sure?");
if(res == JOptionPane.YES_OPTION){
try{Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","r
oot","shagun");
Statement stmt = con.createStatement();
String query = "DELETE FROM dept WHERE deptno =
"+jtf1.getText()+";";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null,"record deleted!");

}
catch(Exception e){
JOptionPane.showMessageDialog(null,"error in deletion!");
 EXIT BUTTON CODING:
System.exit(0);

OUTPUT:

No comments:

Post a Comment