You are on page 1of 38

INFORMATICS

PRACTICES
INVETIGATORY
PROGECT

MADE BY:Ashish Dubey


CLASS:ROLL.NO.:-

Index

XIIth B

1.
Certificate.................................................
..........3
2.
Acknowledgements..................................
...........4
3.
Aim...........................................................
..........5
4.
System
Requirements.........................................6
5.
Form(Snapshots)......................................
.........7
6.
Source
Code......................................................9
7.Bibliography...........................................
..........31

Certificate
This is to certify that Ashish Dubey , student
of Class XII B, KV New Cantt Alld. School has
completed the project titled Smart quiz during
the academic year 2014-2015 towards partial
fulfillment of credit for the Informatic Practices
practical evaluation of CBSE 2015, and
submitted satisfactory report, as compiled in the
following pages, under my supervision.

Mrs.Nidhi Trivedi
KV New Cantt Alld.

Acknowledgements
"There are times when silence speaks so much more loudly than words of
praise to only as good as belittle a person, whose words do not express, but
only put a veneer over true feelings, which are of gratitude at this point of
time."

I would like to express my sincere gratitude to my


physics mentor Mrs.Nidhi Trivedi, for his vital support,
guidance and encouragement - without which this
project would not have come forth. I would also like to
express my gratitude to the staff of the Teachers at
KV New Cantt for their support during the making of
this project. We thank our maam for reviewing the
draft manuscript of the project and for his
constructive suggestions for the development of
this project. We also thanks our principal mam for

providing better facilities and support for the


development of program. Without their support and
excellent guidance, it wouldn't have been possible
to get our ideas compiled in the form of this
Computer Science project.

Aim
To design a java application for a quiz
game named as Smart Quizand also write
a coding for the same with the help of
database connectivity.

System
Requirements
Operating System:
Windows XP or Successive Versions (32 & 64
bit version
supported)

Software Requirements:
NetBeans IDE & MySQL

Form
(Snapshots)

Source Code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* q.java
*
* Created on 3 Jan, 2011, 11:55:00 AM
*/

/**
*
* @author HP
*/import java.sql.*;

import javax.swing.JOptionPane;
public class q extends javax.swing.JFrame {
String n;

String sub;
int sno;
String ques;
String a;
String b;
String c;
String d;
String an;
int rno=0;
int count=0;
String lans=null;

/** Creates new form q */


public q() {
initComponents();
}

/** This method is called from within the constructor to


* initialize the form.

* WARNING: Do NOT modify this code. The content of


this method is
* always regenerated by the Form Editor.

1
0
@SuppressWarnings("unchecked")
*/

//
<editor-fold
desc="Generated Code">

defaultstate="collapsed"

private void initComponents() {

dt = new javax.swing.JDialog();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
rb1 = new javax.swing.JRadioButton();
rb3 = new javax.swing.JRadioButton();
rb2 = new javax.swing.JRadioButton();
rb4 = new javax.swing.JRadioButton();
jButton2 = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
buttonGroup1 = new javax.swing.ButtonGroup();
dq = new javax.swing.JDialog();
jLabel7 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
tq = new javax.swing.JTextArea();

rba = new javax.swing.JRadioButton();


rbb = new javax.swing.JRadioButton();
rbc = new javax.swing.JRadioButton();
rbd = new javax.swing.JRadioButton();

1
1

jButton3 = new javax.swing.JButton();


jButton4 = new javax.swing.JButton();
jLabel11 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
buttonGroup2 = new javax.swing.ButtonGroup();
buttonGroup3 = new javax.swing.ButtonGroup();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
ntf = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();

dt.setTitle("Subject-chooser Screen");
dt.setMinimumSize(new java.awt.Dimension(420,
380));

dt.getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

jLabel4.setFont(new java.awt.Font("Aharoni", 1,
24));
jLabel4.setForeground(new java.awt.Color(255, 51,
102));
jLabel4.setText("WELCOME TO COOL QUIZ");

1
dt.getContentPane().add(jLabel4,
new
org.netbeans.lib.awtextra.AbsoluteConstraints(50,
20, -1,
2
-1));
jLabel5.setFont(new java.awt.Font("Arial Black", 1,
18));
jLabel5.setForeground(new java.awt.Color(153, 0,
0));
jLabel5.setText("Select Your Topic:");
dt.getContentPane().add(jLabel5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(190, 180,
-1, -1));

buttonGroup1.add(rb1);
rb1.setFont(new java.awt.Font("Tahoma", 1, 14));
rb1.setText("Chemistry");
rb1.setOpaque(false);

dt.getContentPane().add(rb1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(180, 210,
-1, -1));

buttonGroup1.add(rb3);
rb3.setFont(new java.awt.Font("Tahoma", 1, 14));
rb3.setText("Java");
rb3.setOpaque(false);
dt.getContentPane().add(rb3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(180, 230,
-1, -1));

buttonGroup1.add(rb2);

1
rb2.setFont(new java.awt.Font("Tahoma",
1, 14));
rb2.setText("History");

rb2.setOpaque(false);
dt.getContentPane().add(rb2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(280, 210,
-1, -1));

buttonGroup1.add(rb4);
rb4.setFont(new java.awt.Font("Tahoma", 1, 14));
rb4.setText("GK");
rb4.setOpaque(false);

dt.getContentPane().add(rb4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(280, 230,
-1, -1));

jButton2.setBackground(java.awt.SystemColor.scroll
bar);
jButton2.setText("Start QUIZ >>>");
jButton2.setBorder(javax.swing.BorderFactory.creat
eMatteBorder(1, 1, 1, 1, new java.awt.Color(255, 0, 0)));
jButton2.addMouseListener(new
java.awt.event.MouseAdapter() {
public
mouseClicked(java.awt.event.MouseEvent evt) {

void

jButton2MouseClicked(evt);
}
});
jButton2.addActionListener(new
java.awt.event.ActionListener()
1{

public
actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

void

dt.getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(250, 260,
100, 30));

jLabel6.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/quiz.jpg
"))); // NOI18N
dt.getContentPane().add(jLabel6,
org.netbeans.lib.awtextra.AbsoluteConstraints(30,
350, 330));

new
10,

dq.setTitle("Question Display Screen");


dq.setMinimumSize(new java.awt.Dimension(500,
420));
dq.getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

jLabel7.setFont(new java.awt.Font("Aharoni", 1,
24));
jLabel7.setForeground(new java.awt.Color(255, 255,
0));
jLabel7.setText("WELCOME TO COOL QUIZ");
dq.getContentPane().add(jLabel7,
org.netbeans.lib.awtextra.AbsoluteConstraints(60,
330, 30));

new
20,

tq.setColumns(20);
tq.setFont(new java.awt.Font("AR CENA", 0, 18)); //
NOI18N
tq.setLineWrap(true);
tq.setRows(5);
tq.setWrapStyleWord(true);
jScrollPane1.setViewportView(tq);

dq.getContentPane().add(jScrollPane1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(30,
80,
430, 80));

buttonGroup2.add(rba);
rba.setFont(new java.awt.Font("Tahoma", 0, 12));
rba.addActionListener(new
java.awt.event.ActionListener() {
public
actionPerformed(java.awt.event.ActionEvent evt) {

void

rbaActionPerformed(evt);
}
});
dq.getContentPane().add(rba,
org.netbeans.lib.awtextra.AbsoluteConstraints(50,
180, -1));

new
190,

buttonGroup2.add(rbb);
rbb.setFont(new java.awt.Font("Tahoma", 0, 12));
dq.getContentPane().add(rbb,
org.netbeans.lib.awtextra.AbsoluteConstraints(50,
180, -1));
1

new
230,

6
buttonGroup2.add(rbc);
rbc.setFont(new java.awt.Font("Tahoma", 0, 12));
dq.getContentPane().add(rbc, new
org.netbeans.lib.awtextra.AbsoluteConstraints(260, 190,
180, 20));

buttonGroup2.add(rbd);
rbd.setFont(new java.awt.Font("Tahoma", 0, 12));
rbd.addActionListener(new
java.awt.event.ActionListener() {
public
actionPerformed(java.awt.event.ActionEvent evt) {

void

rbdActionPerformed(evt);
}
});
dq.getContentPane().add(rbd, new
org.netbeans.lib.awtextra.AbsoluteConstraints(260, 230,
180, -1));

jButton3.setText("RESULT/EXIT");
jButton3.setBorder(new
javax.swing.border.MatteBorder(null));
jButton3.addActionListener(new
java.awt.event.ActionListener() {
public
actionPerformed(java.awt.event.ActionEvent evt) {

void

jButton3ActionPerformed(evt);
}
});
dq.getContentPane().add(jButton3, new
1
org.netbeans.lib.awtextra.AbsoluteConstraints(160, 340,
7
120, 30));

jButton4.setBackground(new java.awt.Color(180,
180, 180));
jButton4.setFont(new java.awt.Font("Andalus", 1,
14));
jButton4.setForeground(new java.awt.Color(51, 0,
204));
jButton4.setText("Get Question>>");
jButton4.setBorder(new
javax.swing.border.MatteBorder(null));
jButton4.addActionListener(new
java.awt.event.ActionListener() {

public
actionPerformed(java.awt.event.ActionEvent evt) {

void

jButton4ActionPerformed(evt);
}
});
dq.getContentPane().add(jButton4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(160, 300,
130, 30));

jLabel11.setFont(new java.awt.Font("Tahoma", 1,
11));
jLabel11.setForeground(new java.awt.Color(51, 51,
51));
jLabel11.setText("A.");
dq.getContentPane().add(jLabel11, new
org.netbeans.lib.awtextra.AbsoluteConstraints(30, 190,
20, -1));

jLabel8.setFont(new java.awt.Font("Tahoma", 1,
11));
jLabel8.setForeground(new java.awt.Color(255, 255,
0));
jLabel8.setText("B.");

1
8

dq.getContentPane().add(jLabel8, new
org.netbeans.lib.awtextra.AbsoluteConstraints(30, 220,
-1, -1));

jLabel10.setFont(new java.awt.Font("Tahoma", 1,
11));
jLabel10.setForeground(new java.awt.Color(255,
255, 0));
jLabel10.setText("C.");
dq.getContentPane().add(jLabel10, new
org.netbeans.lib.awtextra.AbsoluteConstraints(240, 200,
20, 10));

jLabel12.setFont(new java.awt.Font("Tahoma", 1,
11));
jLabel12.setForeground(new java.awt.Color(255,
255, 0));
jLabel12.setText("D.");
dq.getContentPane().add(jLabel12, new
org.netbeans.lib.awtextra.AbsoluteConstraints(240, 230,
20, -1));

jLabel13.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/quizinde
x.jpg"))); // NOI18N
dq.getContentPane().add(jLabel13,
org.netbeans.lib.awtextra.AbsoluteConstraints(-80,
570, 410));

new
-30,

setDefaultCloseOperation(javax.swing.WindowConst
ants.EXIT_ON_CLOSE);
setTitle("Welcome screen");

1
getContentPane().setLayout(new
9
org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel2.setFont(new java.awt.Font("Tempus Sans
ITC", 1, 18));
jLabel2.setForeground(new java.awt.Color(255, 255,
204));
jLabel2.setText("WELCOME TO COOL QUIZ");
getContentPane().add(jLabel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(80, 20, -1,
-1));

jButton1.setBackground(java.awt.SystemColor.contr
olHighlight);
jButton1.setFont(new java.awt.Font("Tahoma", 1,
14));
jButton1.setForeground(new java.awt.Color(102, 0,
51));
jButton1.setText("START QUIZ>>");
jButton1.setBorder(javax.swing.BorderFactory.creat
eLineBorder(new java.awt.Color(0, 0, 0)));
jButton1.addActionListener(new
java.awt.event.ActionListener() {

public
actionPerformed(java.awt.event.ActionEvent evt) {

void

jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(240, 270,
130, 30));

2
0

ntf.setBorder(new
javax.swing.border.MatteBorder(null));
ntf.addActionListener(new
java.awt.event.ActionListener() {
public
actionPerformed(java.awt.event.ActionEvent evt) {

void

ntfActionPerformed(evt);
}
});
getContentPane().add(ntf,
org.netbeans.lib.awtextra.AbsoluteConstraints(60,
270, 30));

new
160,

jLabel1.setFont(new java.awt.Font("Andalus", 1,
14));

jLabel1.setForeground(new java.awt.Color(102, 255,


204));
jLabel1.setText("ENTER YOUR NAME :");
getContentPane().add(jLabel1,
org.netbeans.lib.awtextra.AbsoluteConstraints(60,
-1, -1));

new
140,

jLabel3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/abstract
_05-p_420x315.jpg"))); // NOI18N
getContentPane().add(jLabel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 420,
-1));

pack();
}// </editor-fold>

2
1

private
void
jButton1ActionPerformed(java.awt.event.ActionEvent
evt) {
n=ntf.getText();
dt.setVisible(true);

// TODO add your handling code here:


}

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

dq.setVisible(false);
dt.setVisible(true);
sub=null;
sno=0;
rno=0;
ques=null;
a=null;
b=null;
c=null;
d=null;
an=null;
rno=0;
count=0;
lans=null;
tq.setText(null);
rba.setText(null);
rbb.setText(null);
rbc.setText(null);

2
2

rbd.setText(null);
rba.setSelected(false);
rbb.setSelected(false);
rbc.setSelected(false);
rbd.setSelected(false);

if(rb1.isSelected()){
sub="Chemistry";
dq.setVisible(true);
dt.setVisible(false);

}
if(rb2.isSelected()){
sub="History";
dq.setVisible(true);
dt.setVisible(false);}
if(rb3.isSelected()){
sub="Java";
dq.setVisible(true);
dt.setVisible(false);}
if(rb4.isSelected()){
sub="GK";

2
3

dq.setVisible(true);
dt.setVisible(false);} // TODO add your handling code
here:
}

private
void
rbdActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private
void
rbaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private
void
ntfActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

2
private
void
4
jButton4ActionPerformed(java.awt.event.ActionEvent
evt) {
rno++;

if(rno>1){
if(rba.isSelected()){
if(lans.equals(rba.getText())){
count+=1;}
}
else if(rbb.isSelected()){
if(lans.equals(rbb.getText())){
count+=1;}
}
else if(rbc.isSelected()){
if(lans.equals(rbc.getText())){
count+=1;}
}
else if(rbd.isSelected()){
if(lans.equals(rbd.getText())){
count+=1;}
}
}
if(rno==6){

2
JOptionPane.showMessageDialog(null,sub+"-Quiz
5

over!! "+n+", Your score is "+count );

dt.setVisible(true);
dq.dispose();
}
try
{
Class.forName("java.sql.Driver");
String
"jdbc:mysql://localhost:3306/quizdb";

database

Connection
DriverManager.getConnection(database,
"ashish");

conn =
"root",

Statement stmt = conn.createStatement();

String sq = "select * from " + sub +" where


indx="+rno+";";
ResultSet rs = stmt.executeQuery(sq);
while(rs.next()){
sno=rs.getInt("indx");
ques=rs.getString("question");
a=rs.getString("a");
b=rs.getString("b");
c=rs.getString("c");
d=rs.getString("d");
an=rs.getString("ans");

2
6

rs.close();
stmt.close();
conn.close();
}
}
catch(Exception e){
JOptionPane.showMessageDialog(null,"Error in
connectivity" );
}

tq.setText(""+"Q.No."+sno+". "+ques);
rba.setText(a);
rbb.setText(b);
rbc.setText(c);
rbd.setText(d);
lans=an;
// TODO add your handling code here:
}

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

2
7

JOptionPane.showMessageDialog(null,""+n+", Your score


is "+count );
dt.setVisible(true);
dq.dispose();
// TODO add your handling code here:
}

private
void
jButton2MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new q().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.ButtonGroup
buttonGroup1;
2

8
private javax.swing.ButtonGroup
buttonGroup2;
private javax.swing.ButtonGroup buttonGroup3;
private javax.swing.JDialog dq;
private javax.swing.JDialog dt;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;

private javax.swing.JScrollPane jScrollPane1;


private javax.swing.JTextField ntf;

2
private javax.swing.JRadioButton
rb1;
9

private javax.swing.JRadioButton rb2;


private javax.swing.JRadioButton rb3;
private javax.swing.JRadioButton rb4;
private javax.swing.JRadioButton rba;
private javax.swing.JRadioButton rbb;
private javax.swing.JRadioButton rbc;
private javax.swing.JRadioButton rbd;
private javax.swing.JTextArea tq;
// End of variables declaration

3
0

Bibliography
1.
Informatic Practices Textbook for Class XII(CCE);
National Council of Educational Research and Training.
2.

Togetherwith Class-XII

3. Sumitra Arora-Class-XII
4.

www.wikipedia.com

5. www.sciencealert.com
6. www.google.com
7. www.meritnation.com
\

3
1

Certificate
This is to certify that Jayant Shori , student of
Class XII F, KV New Cantt Alld. School has
completed the project titled Smart quiz during
the academic year 2014-2015 towards partial
fulfillment of credit for the Informatic Practices
practical evaluation of CBSE 2015, and
submitted satisfactory report, as compiled in the
following pages, under my supervision.

Mrs.Nidhi Trivedi
KV New Cantt Alld.

Acknowledgemen
ts
"There are times when silence speaks so much more loudly than words of
praise to only as good as belittle a person, whose words do not express, but
only put a veneer over true feelings, which are of gratitude at this point of
time."

I would like to express my sincere gratitude to my


mentor Mrs.Nidhi Trivedi, for his vital support,
guidance and encouragement - without which this
project would not have come forth. I would also like to
express my gratitude to the staff of the Teachers at
KV New Cantt for their support during the making of
this project. We thank our maam for reviewing the
draft manuscript of the project and for his
constructive suggestions for the development of
this project. We also thanks our principal mam for
providing better facilities and support for the
development of program. Without their support and
excellent guidance, it wouldn't have been possible

to get our ideas compiled in the form of this


Computer Science project.

You might also like