Вы находитесь на странице: 1из 60

CUMPUTER

SCIENCE
PROJECT'S

- PRAVEER NARAVRIYA
HERE I AM GIVING YOU SOME
COMPUTER SCIENCE ROJECTS
THERE SOURCE CODE . BY THE HELP
OF THIS YOU CAN SIMPLY DO YOUR
PROJECT'S .

THIS IS ONLY FOR MY ALLTIME


LOVELY FRIENDS.
CONTENTS -
1)A QUICK AND EASY ERROR HANDLER

2)CONNECTING JAVA WITH MS-ACCESS - INSERTING DATA IN

3) SENDING MAIL USING JAVAMAIL TO YAHOO AND GMAIL


ACCOUNTS

4) STUDENT MGM

5) CLASSIC GAME OF SNAKE & LADDER

6) VIRUS JOKE PROGRAM


A QUICK AND EASY ERROR HANDLER!!
DESCRIPTION:IN JUST A FEW EASY LINES YOU CAN A HAVE A
EASY, ERROR PROOF ERROR HANDLER FOR YOU APPS! PLUS,
NO APIS

Sub ErrHandler

ErrDesc = Err.Description
ErrNum = Err.Number
Beep
MsgBox "Error number " & ErrNum & " has occured because: " &_
ErrDesc, vbCritical, "Error"
Exit Sub
'Edit the msgbox all ya want to make it
' fit your needs
End Sub

'Ok, now to make my error handler work y


' ou need to
'add this right under the Sub...Examle:

Private Sub Command1_Click ()

'Now Here Is the code you need to add:


On Error Goto ErrHandle:
'Then put ALL your code for this Sub in
' as you would
'as usual, then at the end type:
ErrHandle:
Call ErrHandler
'AND THATS IT!
End Sub
Connecting Java with MS-Access - Inserting data in

import java.sql.*;
import java.math.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

/* author: aseem shrestha */


/* database connectivity with MS-Access is done by creating
DataSourceName(dsn) in this example*/
/* Steps to use this example:
* go to ms-access and make a table called "student_base" and give it a
file name student_base.mdb
* 1. Go to Control Panel
2. Click on Administrative Tools(windows 2000/xp), Click on
ODBC(win98)
3. click on ODBC
4. Then , you will see a ODBC dialog box. Click on UserDSn
5. Click on Add Button
6. Select Microsoft Access Driver(*.mdb) driver and click on finish
7. Give a Data Source Name : student_base
8. Then Click on Select
9. Browse on the database name you have created and click
it:student_base.mdb is a database file where all data
will be stored
10. Click on OK.
Once the DSN is created, you can do this example*/

public class AddNewStudent extends JFrame implements ActionListener {

private JButton btnok,btnexit,btnaddnew; //buttons


private JTextField tf1,tf2;//textfields
private JLabel lblname,lbladd,lblmsg; //labels

private JPanel p1,p2,p3,psouth; //panels

public AddNewStudent() //constructor


{
//initializing buttons
btnok = new JButton("OK");
btnok.addActionListener(this);
btnexit = new JButton("Exit");
btnexit.addActionListener(this);
btnaddnew = new JButton("AddNew");
btnaddnew.addActionListener(this);

//initializing textfields
tf1 = new JTextField(12);
tf2 = new JTextField(12);
//initializing labels

lblname = new JLabel("Name:");


lbladd = new JLabel("Address:");
lblmsg = new JLabel("",JLabel.CENTER);

//initializing panels
p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel();
psouth = new JPanel();

//adding buttons and label to panel p1


//setting flowlayout
p1.setLayout(new FlowLayout());

p1.add(btnok);
p1.add(btnexit);
p1.add(btnaddnew);
//adding lblmsg to panel p3
p3.add(lblmsg);

//adding both the panels to new panel,psouth


//settin layout 2:1
psouth.setLayout(new GridLayout(2,1));
psouth.add(p3);
psouth.add(p1);

//adding label and textfields to panel p2


p2.setLayout(new GridLayout(3,1));
//setting line and titled border for panel p2
p2.setBorder(BorderFactory.createLineBorder(Color.red));
p2.setBorder(BorderFactory.createTitledBorder("Enter Your
Details"));
p2.add(lblname);
p2.add(tf1);
p2.add(lbladd);
p2.add(tf2);
//adding panel to container
this.getContentPane().add(p2,"Center");
this.getContentPane().add(psouth,"South");

this.setSize(300,300);
this.setLocation(100,200);
this.show();

}
public static void main(String args[])
{
AddNewStudent ad = new AddNewStudent();
}

//event handling
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btnok)
{
PreparedStatement pstm;
ResultSet rs;
String sql;
//if no entries has been made and hit ok button throw an error
//you can do this step using try clause as well
if((tf1.getText().equals("")&&(tf2.getText().equals(""))))
{
lblmsg.setText("Enter your details ");
lblmsg.setForeground(Color.magenta);
}

else
{

try
{
//loading the driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

//connection object created using DriverManager class


//student_base is the name of the database
Connection connect =
DriverManager.getConnection("jdbc:odbc:student_base");
//creating prepared statement object pstm so that query can be
sent to database
pstm=connect.prepareStatement("insert into student_base
values(?,?)");
pstm.setString(1,tf1.getText());
pstm.setString(2,tf2.getText());
//execute method to execute the query
pstm.executeUpdate();
lblmsg.setText("Details have been added to database");

//closing the prepared statement and connection object


pstm.close();
connect.close();
}
catch(SQLException sqe)
{
System.out.println("SQl error");
}
catch(ClassNotFoundException cnf)
{
System.out.println("Class not found error");
}
}
}
//upon clickin button addnew , your textfield will be empty to
enter
next record
if(e.getSource()==btnaddnew)
{
tf1.setText("");
tf2.setText("");
}

if(e.getSource()==btnexit)
{
System.exit(1);
}
}
}
Sending mail Using JavaMail to Yahoo and Gmail accounts

import java.io.File;
import java.security.Security;
import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

public class GoogleTest {

private static final String SMTP_HOST_NAME = "smtp.gmail.com";


private static final String SMTP_PORT = "465";
private static final String emailMsgTxt = "Test Message Contents";
private static final String emailSubjectTxt = "A test from gmail";
private static final String emailFromAddress = "xxx@gmail.com";
private static final String SSL_FACTORY =
"javax.net.ssl.SSLSocketFactory";
private static final String[] sendTo = {"xxx@gmail.com","xxx@yahoo.com"};

private static final String fileAttachment="D:\hai.txt";

public static void main(String args[]) throws Exception {

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

new GoogleTest().sendSSLMessage(sendTo, emailSubjectTxt,


emailMsgTxt, emailFromAddress);
System.out.println("Sucessfully Sent mail to All Users");

public void sendSSLMessage(String recipients[], String subject,


String message, String from) throws MessagingException {
boolean debug = true;
Properties props = new Properties();
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.smtp.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
props.put("mail.smtp.socketFactory.fallback", "false");

Session session = Session.getDefaultInstance(props,


new javax.mail.Authenticator() {

protected PasswordAuthentication getPasswordAuthentication() {


return new PasswordAuthentication("xxx@gmail.com", "give password of
gmail");
}
});

MimeMessage message1 =
new MimeMessage(session);
message1.setFrom(
new InternetAddress(from));
message1.addRecipient(
Message.RecipientType.TO,
new InternetAddress(recipients[0]));

message1.addRecipient(
Message.RecipientType.TO,
new InternetAddress(recipients[1]));

message1.setSubject(
"Hello JavaMail Attachment");

// create the message part


MimeBodyPart messageBodyPart =
new MimeBodyPart();

//fill message
messageBodyPart.setText("Hi");

Multipart multipart = new MimeMultipart();


multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source =
new FileDataSource(fileAttachment);
messageBodyPart.setDataHandler(
new DataHandler(source));
messageBodyPart.setFileName(fileAttachment);
multipart.addBodyPart(messageBodyPart);

// Put parts in message


message1.setContent(multipart);

// Send the message


Transport.send( message1 );
}
}
STUDENT MANAGEMENT

import java.io.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class menu extends Frame implements


WindowListener,ActionListener
{
MenuBar mb;
MenuItem student,rollnowise,namewise,allresult;
public static menu m;
rollnowise rw;
namewise n;
student st;
int x,y,d;

public menu()
{
super("menu ARPAN");
addWindowListener(this);
x=y=700;
d=10;
setSize(x,y);
setBackground(Color.orange);
addMenu();
show();
}

public static void main(String args[])


{
m=new menu();
}

void addMenu()
{
MenuBar mb=new MenuBar();
Menu register=new Menu("REGISTER");
Menu inquery=new Menu("INQUERY");
register.add("STUDENT");
register.add("EXIT");
inquery.add("ROLLNOWISE");
inquery.add("NAMEWISE");

mb.add(register);
mb.add(inquery);

setMenuBar(mb);

register.addActionListener(this);
inquery.addActionListener(this);

public void actionPerformed(ActionEvent ae)

{
String arg=ae.getActionCommand();
if(ae.getSource() instanceof Menu)
if(arg.equals("EXIT"))
{
System.exit(0);
}
if(ae.getSource() instanceof Menu)
if("STUDENT".equals(arg))
{
st=new student();
st.show();
}
if(ae.getSource() instanceof Menu)
if("ROLLNOWISE".equals(arg))
{
rw=new rollnowise();
rw.show();
}
if(ae.getSource() instanceof Menu)
if("NAMEWISE".equals(arg))
{
n=new namewise();
n.show();
}
}

public void windowClosed(WindowEvent we){}


public void windowDeiconified(WindowEvent we){}
public void windowIconified(WindowEvent we){}
public void windowActivated(WindowEvent we){}
public void windowDeactivated(WindowEvent we){}
public void windowOpened(WindowEvent we){}
public void windowClosing(WindowEvent we)
{

while(x>0 && y>0)

{
setSize(x,y);
x=x-d;
y=y-d;
show();
}
System.out.println("mail me at arpankumarsingh@yahoo.com");
dispose();
System.exit(0);

}
}

//class for name wise report

class namewise extends Frame implements WindowListener,ActionListener


{
public static namewise nw;
Label l1=new Label("NAME",Label.LEFT);
Label l2=new Label("ROLLNO",Label.LEFT);
Label l3=new Label("COLG",Label.LEFT);
Label l4=new Label("SUB1",Label.LEFT);
Label l5=new Label("SUB2",Label.LEFT);
Label l6=new Label("SUB3",Label.LEFT);
Label l7=new Label("SUB4",Label.LEFT);
Label l8=new Label("SUB5",Label.LEFT);
TextField tf_entername=new TextField(20);
Button but_entername =new Button("FIND");
Button ok=new Button("OK");
Graphics g;
String sqlstr;
Statement st;
GridLayout gl=new GridLayout(1,2);
GridLayout cl=new GridLayout(1,5);

Font font18=new Font("VinetaBT",Font.BOLD|Font.ITALIC,18);

int x,y,d;
Dialog dlg;
Label msg;
public namewise()
{
super("NAMEWISE");
addWindowListener(this);
setLayout(new GridLayout(12,1));
setBackground(Color.orange);
setForeground(Color.black);
addMenu();
x=550;

y=450;
d=100;
setSize(x,y);
show();
}

void addMenu()
{
Panel p4=new Panel();
Label l11=new Label("ENTERNAME");

p4.add(l11);
p4.add(tf_entername);
p4.add(but_entername);
add(p4);

but_entername.addActionListener(this);
ok.addActionListener(this);

//Dialog for confirmation

dlg=new Dialog(this,"Inventory Management System",false);


dlg.setLayout(new GridLayout(2,1));
dlg.setSize(100,100);
dlg.setLocation(200,100);
ok.setSize(50,50);
msg=new Label("NAME NOT FOUND");
dlg.add(msg);
dlg.add(ok);

public void actionPerformed(ActionEvent e)


{
Panel p1=new Panel();
l1.setFont(font18);
l2.setFont(font18);
p1.setLayout(gl);

p1.add(l1);
p1.add(l2);
g=getGraphics();
g.drawLine(40,0,40,0);

Panel p2=new Panel();


l3.setFont(font18);
p2.add(l3);
p2.setLayout(gl);

Panel p3=new Panel();


l4.setFont(font18);
l5.setFont(font18);
l6.setFont(font18);
l7.setFont(font18);
l8.setFont(font18);

p3.add(l4);
p3.add(l5);
p3.add(l6);
p3.add(l7);
p3.add(l8);
p3.setLayout(cl);

String arg=e.getActionCommand();
if(e.getSource() instanceof Button)
if("FIND".equals(arg))
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:stu","","");
sqlstr="select * from stu1 where NAME='"+
tf_entername.getText()+"'";
st=con.createStatement();
ResultSet rs;
rs= st.executeQuery(sqlstr);

while(rs.next())
{
Panel a1=new Panel();
l1=new Label("",Label.LEFT);
l2=new Label("",Label.LEFT);
l1.setFont(font18);
l2.setFont(font18);
a1.setLayout(gl);
Panel a2=new Panel();
l3=new Label("",Label.LEFT);

l3.setFont(font18);
a2.setLayout(gl);

Panel a3=new Panel();


l4=new Label("",Label.LEFT);
l5=new Label("",Label.LEFT);
l6=new Label("",Label.LEFT);
l7=new Label("",Label.LEFT);
l8=new Label("",Label.LEFT);
l4.setFont(font18);

l5.setFont(font18);

l6.setFont(font18);

l7.setFont(font18);

l8.setFont(font18);
a3.setLayout(cl);

l1.setText(rs.getString("NAME"));
l2.setText(""+rs.getInt("ROLLNO"));
l3.setText(rs.getString("COLG"));
l4.setText(""+rs.getInt("SUB1"));
l5.setText(""+rs.getInt("SUB2"));
l6.setText(""+rs.getInt("SUB3"));
l7.setText(""+rs.getInt("SUB4"));
l8.setText(""+rs.getInt("SUB5"));

a1.add(l1);
a1.add(l2);

a2.add(l3);

a3.add(l4);
a3.add(l5);
a3.add(l6);
a3.add(l7);
a3.add(l8);

add(p1);
add(a1);

add(p2);
add(a2);

add(p3);
add(a3);
show();

}
}
catch(ClassNotFoundException se)
{
tf_entername.setText("Error : " + se.toString());

}
catch(SQLException se)
{
tf_entername.setText("Error : " + se.toString());

}
}

public void windowClosed(WindowEvent we){}


public void windowDeiconified(WindowEvent we){}
public void windowIconified(WindowEvent we){}
public void windowActivated(WindowEvent we){}
public void windowDeactivated(WindowEvent we){}
public void windowOpened(WindowEvent we){}

public void windowClosing(WindowEvent we)


{
while(x>0 && y>0)
{
setSize(x,y);
x=x-d;
y=y-d;
show();
}
dispose();

}
}

//class for rollnowise report


class rollnowise extends Frame implements
WindowListener,ActionListener
{

public static rollnowise rw;


Label l1=new Label("NAME",Label.LEFT);
Label l2=new Label("ROLLNO",Label.LEFT);
Label l3=new Label("COLG",Label.LEFT);
Label l4=new Label("SUB1",Label.LEFT);
Label l5=new Label("SUB2",Label.LEFT);
Label l6=new Label("SUB3",Label.LEFT);
Label l7=new Label("SUB4",Label.LEFT);
Label l8=new Label("SUB5",Label.LEFT);

TextField tf_entername=new TextField(20);


Button but_entername =new Button("FIND");
String sqlstr;
Statement st;
GridLayout gl=new GridLayout(1,2);
GridLayout cl=new GridLayout(1,5);

Font font18=new Font("VinetaBT",Font.BOLD|Font.ITALIC,18);

int x,y,d;

public rollnowise()
{
super("ROLLNOWISE");
addWindowListener(this);
setLayout(new GridLayout(12,1));
setBackground(Color.orange);
setForeground(Color.black);
addMenu();
x=550;
y=450;
d=100;
setSize(x,y);
show();
}

void addMenu()
{
Panel p4=new Panel();
Label l11=new Label("ENTERROLLNO");

p4.add(l11);
p4.add(tf_entername);
p4.add(but_entername);
add(p4);

but_entername.addActionListener(this);
}

public void actionPerformed(ActionEvent e)


{
Panel p1=new Panel();
l1.setFont(font18);
l2.setFont(font18);
p1.setLayout(gl);
p1.add(l1);
p1.add(l2);
l3.setFont(font18);
Panel p2=new Panel();
p2.add(l3);
p2.setLayout(gl);

Panel p3=new Panel();

l4.setFont(font18);

l5.setFont(font18);

l6.setFont(font18);

l7.setFont(font18);

l8.setFont(font18);
p3.add(l4);
p3.add(l5);
p3.add(l6);
p3.add(l7);
p3.add(l8);
p3.setLayout(cl);

/* Panel p4=new Panel();


Label l11=new Label("ENTERROLLNO");

p4.add(l11);
p4.add(tf_entername);
p4.add(but_entername);
add(p4);
add(p1);
add(p2);
add(p3);
*/
String arg=e.getActionCommand();
if(e.getSource() instanceof Button)
if("FIND".equals(arg))
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:stu","","");
sqlstr="select * from stu1 where ROLLNO="+
tf_entername.getText()+"";
st=con.createStatement();
ResultSet rs;
rs= st.executeQuery(sqlstr);

while(rs.next())
{
Panel a1=new Panel();
l1=new Label("",Label.LEFT);
l2=new Label("",Label.LEFT);
l1.setFont(font18);
l2.setFont(font18);
a1.setLayout(gl);

Panel a2=new Panel();


l3=new Label("",Label.LEFT);
l3.setFont(font18);
a2.setLayout(gl);

Panel a3=new Panel();


l4=new Label("",Label.LEFT);
l5=new Label("",Label.LEFT);
l6=new Label("",Label.LEFT);
l7=new Label("",Label.LEFT);
l8=new Label("",Label.LEFT);
l4.setFont(font18);

l5.setFont(font18);

l6.setFont(font18);

l7.setFont(font18);

l8.setFont(font18);
a3.setLayout(cl);

l1.setText(rs.getString("NAME"));
l2.setText(""+rs.getInt("ROLLNO"));
l3.setText(rs.getString("COLG"));
l4.setText(""+rs.getInt("SUB1"));
l5.setText(""+rs.getInt("SUB2"));
l6.setText(""+rs.getInt("SUB3"));
l7.setText(""+rs.getInt("SUB4"));
l8.setText(""+rs.getInt("SUB5"));

a1.add(l1);
a1.add(l2);

a2.add(l3);

a3.add(l4);
a3.add(l5);
a3.add(l6);
a3.add(l7);
a3.add(l8);

add(p1);
add(a1);

add(p2);
add(a2);

add(p3);
add(a3);
show();
}
}
catch(ClassNotFoundException se)
{

tf_entername.setText("Error : " + se.toString());


}

catch(SQLException se)
{
tf_entername.setText("Error : " + se.toString());
}
}

public void windowClosed(WindowEvent we){}


public void windowDeiconified(WindowEvent we){}
public void windowIconified(WindowEvent we){}
public void windowActivated(WindowEvent we){}
public void windowDeactivated(WindowEvent we){}
public void windowOpened(WindowEvent we){}

public void windowClosing(WindowEvent we)


{
while(x>0 && y>0)
{
setSize(x,y);
x=x-d;
y=y-d;
show();
}
dispose();

}
}

//class which help in storing records in the database


class student extends Frame implements ActionListener,WindowListener
{
public static student st;

TextField tf_name=new TextField(20);


TextField tf_rollno=new TextField(20);
TextField tf_colg=new TextField(20);
TextField tf_marks=new TextField(20);
TextField tf_sub1=new TextField(4);
TextField tf_sub2=new TextField(4);
TextField tf_sub3=new TextField(4);
TextField tf_sub4=new TextField(4);
TextField tf_sub5=new TextField(4);

Label l2=new Label("ROLLNO");


Label l1=new Label("NAME");
Label l3=new Label("MARKS");
Label l4=new Label("COLG");
Label l5=new Label("MARK SHEET");
Label l6=new Label("SUB1");
Label l7=new Label("SUB2");
Label l8=new Label("SUB3");
Label l9=new Label("SUB4");
Label l10=new Label("SUB5");
Button but_add=new Button("ADD");
Button but_edit=new Button("EDIT");
Button but_find=new Button("FIND");
Button but_delete=new Button("DELETE");
Button but_cancel=new Button("CANCEL");
Button ok=new Button("OK");
Dialog dlg;
Label msg;
int x,y,d;

public student()
{
super("palce");
addWindowListener(this);
setLayout(new GridLayout(6,1));
setBackground(Color.yellow);
setVisible(true);
addmenu();
x=550;
y=450;
d=12;
setSize(x,y);
show();
}

void addmenu()
{
//GridLayout gl=new GridLayout();

Panel p1=new Panel();


p1.add(l1);
p1.add(tf_name);

p1.add(l2);
p1.add(tf_rollno);

Panel p2=new Panel();


p2.add(l5);
Panel p3=new Panel();
p3.add(but_add);
p3.add(but_find);
p3.add(but_cancel);
p3.add(but_edit);
p3.add(but_delete);

Panel p4=new Panel();


//p4.add(l3);
p4.add(l6);
p4.add(l7);
p4.add(l8);
p4.add(l9);
p4.add(l10);

Panel p8=new Panel();


p8.add(tf_sub1);
p8.add(tf_sub2);
p8.add(tf_sub3);
p8.add(tf_sub4);
p8.add(tf_sub5);

Panel p5=new Panel();


p5.add(l4);
p5.add(tf_colg);

add(p2);
add(p1);
add(p5);
add(p4);
add(p8);
add(p3);
but_add.addActionListener(this);
but_cancel.addActionListener(this);
but_find.addActionListener(this);
but_delete.addActionListener(this);
but_edit.addActionListener(this);
ok.addActionListener(this);
//Dialog for confirmation

dlg=new Dialog(this,"Inventory Management System",false);


dlg.setLayout(new GridLayout(2,1));
dlg.setSize(100,100);
dlg.setLocation(200,100);
ok.setSize(50,50);
msg=new Label("Record Updated");
dlg.add(msg);
dlg.add(ok);

}
public void actionPerformed(ActionEvent e)
{
String arg=e.getActionCommand();
//ADDBUTTON
if(e.getSource() instanceof Button)
if("ADD".equals(arg))
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:stu","","");
Statement st;

String sqlStr;
sqlStr="insert into
stu1(NAME,ROLLNO,COLG,SUB1,SUB2,SUB3,SUB4,SUB5)values('"+tf_name.getText()
+"',"+tf_rollno.getText()+",'"+tf_colg.getText()+"',"+tf_sub1.getText()+",
"+tf_sub2.getText()+","+tf_sub3.getText()+","+tf_sub4.getText()+","+tf_sub
5.getText()+")";
st=con.createStatement();
st.executeUpdate(sqlStr);
}
catch(ClassNotFoundException se)
{
// tf_name.setText("Error : " + se.toString());
msg.setText("ERROR");
dlg.show();
}
catch(SQLException se)
{
// tf_name.setText("Error : " + se.toString());
msg.setText("ENTER TEXTFIELD");
dlg.show();
}

//OK button

if ( e.getSource() instanceof Button)


if ("OK".equals(arg))
{ dlg.dispose();
}

//CANCEL
if(e.getSource() instanceof Button)
if("CANCEL".equals(arg))

{
tf_name.setText("");
tf_rollno.setText("");
tf_colg.setText("");
tf_sub1.setText("");
tf_sub2.setText("");
tf_sub3.setText("");
tf_sub4.setText("");
tf_sub5.setText("");
}
//FIND
if(e.getSource() instanceof Button)
if("FIND".equals(arg))
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:stu","","");
Statement st;
String sqlstr;
sqlstr="select * from stu1 where ROLLNO ="+tf_rollno.getText()+"";
st=con.createStatement();
ResultSet rs;
rs=st.executeQuery(sqlstr);
rs.next();
tf_name.setText(""+rs.getString("NAME"));
tf_colg.setText(""+rs.getString("COLG"));
tf_sub1.setText(""+rs.getInt("SUB1"));
tf_sub2.setText(""+rs.getInt("SUB2"));
tf_sub3.setText(""+rs.getInt("SUB3"));
tf_sub4.setText(""+rs.getInt("SUB4"));
tf_sub5.setText(""+rs.getInt("SUB5"));
}
catch(ClassNotFoundException se)
{
msg.setText("RECORD NOT FOUND");
dlg.show();

// tf_name.setText("Error : " + se.toString());


}
catch(SQLException se)
{
msg.setText("RECORD NOT FOUND");
dlg.show();
//tf_name.setText("Error : " + se.toString());
}

//DELETE
if(e.getSource() instanceof Button)
if("DELETE".equals(arg))
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:stu","","");
Statement st;
String sqlstr;
sqlstr="delete * from stu1 where ROLLNO="+tf_rollno.getText()+"";
st=con.createStatement();
st.executeUpdate(sqlstr);
tf_name.setText("");
tf_colg.setText("");
tf_sub1.setText("");
tf_sub2.setText("");
tf_sub3.setText("");
tf_sub4.setText("");
tf_sub5.setText("");

tf_rollno.setText("");
msg.setText("RECORD DELETED");
dlg.show();

}
catch(ClassNotFoundException se)
{
tf_name.setText("Error : " + se.toString());
}
catch(SQLException se)
{
tf_name.setText("Error : " + se.toString());
}

//EDIT
if(e.getSource() instanceof Button)
if("EDIT".equals(arg))
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:stu","","");
Statement st;
String sqlstr;
sqlstr="update stu1 set
NAME='"+tf_name.getText()+"',SUB1="+tf_sub1.getText()+",SUB2="+tf_sub2.get
Text()+",SUB3="+tf_sub3.getText()+",SUB4="+tf_sub4.getText()+",SUB5="+tf_s
ub5.getText()+",COLG='"+tf_colg.getText()+"' where
ROLLNO="+tf_rollno.getText();
st=con.createStatement();
st.executeUpdate(sqlstr);
msg.setText("RECORD UPDATED");

dlg.show();
}
catch(ClassNotFoundException se)
{

tf_name.setText("Error : " + se.toString());


}
catch(SQLException se)
{

tf_name.setText("Error : " + se.toString());


}
}
public void windowClosed(WindowEvent we){}
public void windowDeiconified(WindowEvent we){}
public void windowIconified(WindowEvent we){}
public void windowActivated(WindowEvent we){}
public void windowDeactivated(WindowEvent we){}
public void windowOpened(WindowEvent we){}
public void windowClosing(WindowEvent we)
{
while(x>0 && y>0)
{
setSize(x,y);
x=x-d;
y=y-d;
show();
}
dispose();
}

ANIMATED 3D CAR IN C++ CODING

#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<process.h>

void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\tc\bgi");
int c=12;
setbkcolor(0);
//setlinestyle(0,1,2);

int t;
while(1)
{
settextstyle(2,0,5);
outtextxy(100,10,"Press L,H ,T,P");
outtextxy(100,30,"Press 1 for Quit");
as:
setcolor(13);
ellipse(380,127,20,152,130,35);
//////////////////////////////rear//////////////////////////

line(490,109,560,142);
line(560,142,569,142);
line(569,142,582,102);
line(582,102,620,92);
line(593,132,617,125);

line(617,124,627,96);
line(620,92,628,97);

line(472,86,602,96);
line(501,113,575,121);
line(443,77,475,80);

line(443,77,432,93);
line(475,80,472,85);
//setcolor(4);
line(593,132,593,137);
line(593,137,600,141);
line(600,141,600,185);
line(600,185,608,192);
line(608,192,608,234);
line(608,234,586,253);
line(586,253,577,248);

///////////////////////// mirror
line(263,112,363,127);
line(193,160,263,112);
line(193,160,220,170);
line(220,170,280,180);
line(280,180,320,185);
line(320,185,363,127);
////////////////////////////////sidemirror
line(340,194,460,169);
line(460,169,519,152);

ellipse(512,144,300,30,10,10);
ellipse(467,143,28,100,50,30);
line(510,128,521,138);
line(435,116,440,171);

// setcolor(4);
////////////////////////////////////////cont//
line(339,194,372,144);
// line(372,140,386,128);
ellipse(454,208,87,123,128,95);
line(372,144,384,128);
int b,x,y;
////////////////////////lower
line(365,298,524,264);
line(365,298,330,310);
line(330,310,323,310);

///////////////////////////////bumper
ellipse(162,221,135,190,90,40);
line(96,193,140,174);
line(140,174,160,168);
line(160,168,192,161);

//////////////////////front
ellipse(75,246,95,190,18,18);
line(57,251,57,286);
//setcolor(4);
ellipse(181,178,232,263,200,137);
ellipse(195,180,256,286,200,137);

ellipse(191,171,228,247,200,100);
ellipse(231,198,234,275,200,80);

//setcolor(9);
//ellipse(195,170,256,286,200,137);
//setcolor(12);

ellipse(196,167,228,246,200,90);
ellipse(231,184,234,276,200,80);

ellipse(191,200,228,246,200,90);
ellipse(228,218,234,276,200,80);

ellipse(258,268,180,220,200,40);
ellipse(178,296,244,355,16,10);

ellipse(238,249,227,250,200,60);

/////////////wheel1
ellipse(302,281,320,77,26,45);
ellipse(290,277,65,162,40,45);

ellipse(278,288,144,212,31,45);

/////////////wheel2
//setcolor(5);
ellipse(302+260,229,328,87,26,45);
ellipse(290+280-7,277-50+2,90,162,40,45);
ellipse(278+270,288-50,144,215,27,45);
b=0;
int v=0;

/////////
ellipse(302+250+v,227+b,295,90,29,41);
ellipse(302+234+v,231+b,245,306,50,40);
//setlinestyle(3,0,3);
ellipse(302+248+v,229+b,0,360,21,30);

ellipse(302+247+v,229+b,0,360,8,10);
setfillstyle(6,11);
//floodfill(302+248+v,230+b,13);
//line(546,201,546,257);
//line(554,201,554,257);
//setcolor(4);

line(546+v,201+b,546+v,220+b);
line(551+v,201+b-2,551+v,220+b);

line(546+v,238+b,546+v,257+b);
line(551+v,238+b+2,551+v,257+b+2);

line(530+v,225+b,541+v,225+b);
line(530+v,230+b,541+v,230);

line(557+v,225+b,570+v,225+b);
line(557+v,230+b,570+v,230+b);

line(563+v,206+b,552+v,222+b);
line(534+v,246+b,543+v,232+b);

line(566+v,210+b,556+v,223+b);
line(536+v,250+b,544+v,238+b);

line(536+v,207+b,546+v,222+b);
line(532+v,213+b,542+v,224+b);

line(556+v,235+b,566+v,247+b);
line(551+v,237+b,563+v,253+b);

////////////////////////////////////////////////////
v=-260;
b=56;
ellipse(302+233+v,221+b,260,60,49,51);
//ellipse(302+234+v,231+b,245,306,50,40);
//setlinestyle(3,0,3);
ellipse(302+243+v,224+b,0,360,28,35);
// line(249,328,269,328);
ellipse(300+245+v,223+b,0,360,10,12);

ellipse(285+249+v,239+b,210,260,30,33);
//floodfill(285+258+v,230+b,12);
b=45;
v=v-4;
line(546+v,201+b,546+v,220+b+2);
line(551+v,201+b,551+v,220+b+2);
b=b+8;
line(546+v,238+b,546+v,257+b+4);
line(551+v,238+b,551+v,257+b+4);
v=v-2;
line(530+v-6,225+b,541+v,225+b);
line(530+v-6,230+b,541+v,230+b);
v=v+5;
line(557+v,225+b,570+v+3,225+b);
line(557+v-1,230+b,570+v+3,230+b);

b=b-5;
v=v-5;
line(565+v+3,206+b,552+v+4,222+b-2);
b=b+15;

line(534+v,246+b,543+v+3,232+b-5);
b=b-10;
line(566+v+7,210+b-5,556+v+4,220+b);
line(536+v-5,250+b,544+v-2,238+b-4);

line(536+v,207+b-8,545+v,222+b-5);
line(531+v,212+b-8,542+v,224+b-2);

line(556+v,235+b,566+v+3,247+b+5);
line(551+v,237+b,563+v+2,253+b+3);

///////////////////lights
ellipse(199,250,144,345,18,8);
line(185,245,206,230);
//setcolor(4);
ellipse(223,234,340,110,8,5);
line(230,237,217,252);
line(206,230,220,229);

//setfillstyle(1,4);

//floodfill(200,240,12);

/////////////////////////////////////
line(90,223,152,236);
line(152,236,137,254);
line(90,223,90,242);

//setfillstyle(10,9);
//floodfill(91,230,14);
ellipse(240,270,104,136,100,60);
ellipse(185,237,120,160,100,60);
ellipse(80,221,357,134,10,10);

line(152,236,168,228);
///////////////////////////////////////////////
line(435,116,440,171);
//////////////////////////////////////////hp
//line(134,185,220,210);
line(134,185,196,160);
line(214,212,318,185);
/////////////////////////////////////////////////light

//setcolor(14);
ellipse(166,247,99,330,8,8);
ellipse(171,243,310,129,7,7);
putpixel(174,250,13);
putpixel(173,251,13);
putpixel(164,239,13);
putpixel(165,238,13);

/////////////////////////////////////////road/////////////////////
setcolor(13);
line(1,430,639,300);
line(1,445,639,315);

line(1,210,93,194);
line(1,195,194,158);

//line(1,170,639,71);
//line(1,170,229,135);
line(520,90,639,71);
line(478,86,639,56);

int c=0;

line(10,194+c,10,208+c);
line(40,189+c,40,204+c);
line(70,183+c,70,198+c);
line(100,176+c,100,190+c);

line(130,170+c,130,177+c);
line(160,166+c,160,168+c);
line(190,160+c,190,161+c);

line(190+330,78+c,190+330,89+c);

line(190+360,72+c,190+360,85+c);
line(190+390,67+c,190+390,81+c);
line(190+420,62+c,190+420,76+c);
line(190+449,57+c,190+449,71+c);

c=236;

line(10,192+c,10,208+c);
line(40,189+c-2,40,204+c-3);
line(70,183+c-3,70,198+c-3);
line(100,176+c-2,100,190+c-2);
line(130,170+c-2,130,177+c+5);
line(160,166+c-3,160,168+c+8);
line(190,160+c-4,190,161+c+9);

line(190+30,156+c-5,190+30,170+c-5);

line(190+30+30,156+c-12,190+30+30,170+c-12);

line(190+90,156+c-18,190+90,170+c-17);

line(190+120,156+c-25,190+120,170+c-25);

line(190+150,156+c-30,190+150,170+c-30);

line(190+180,156+c-37,190+180,170+c-36);

line(190+210,156+c-42,190+210,170+c-42);

line(190+240,156+c-48,190+240,170+c-48);

line(190+270,156+c-55,190+270,170+c-54);

line(190+300,156+c-61,190+300,170+c-61);
line(190+330,78+c+10,190+330,89+c+13);

line(190+360,72+c+11,190+360,85+c+13);
line(190+390,67+c+10,190+390,81+c+10);
line(190+420,62+c+8,190+420,76+c+10);
line(190+449,57+c+8,190+449,71+c+8);

/////////////////road

setcolor(12); /////////////////////////////1

line(1,310,25,306);
line(6,318,30,315);
line(1,310,6,318);
line(25,306,30,314);
int k,m;
k=13*45+19;
m=16*(-8);
//2
setcolor(12);

line(605,310-128,629,306-128);
line(610,318-128,634,315-128);
line(605,310-128,610,318-128);
line(629,306-128,634,314-128);

setcolor(12); //////////////////////////////////3
k=45;
m=-8;
line(46,302,70,298);
line(51,310,75,307);
line(46,302,51,310);
line(70,298,75,306);
// PRAVEER //

setfillstyle(1,0);
floodfill(64,303,12);

setfillstyle(1,14);
floodfill(14,314,12);
floodfill(617,183,12);

setfillstyle(1,0);
floodfill(14,314,12);
floodfill(617,183,12);

setfillstyle(1,14);
floodfill(64,303,12);

t=getch();

if(t=='1')
exit(0);
if(t=='h')
{
sound(710);
delay(500);
nosound();
//break;
}
if(t=='t')
{
while(!kbhit()) {
setfillstyle(1,0);
floodfill(536,213,13);
floodfill(563,213,13);
floodfill(561,244,13);
floodfill(538,244,13);
floodfill(274,295,13);
floodfill(294,295,13);
floodfill(274,265,13);
floodfill(294,265,13);
floodfill(548,250,13);
floodfill(548,214,13);
floodfill(533,228,13);
floodfill(563,228,13);
floodfill(262,281,13);
floodfill(308,281,13);
floodfill(284,251,13);
floodfill(284,295,13);

setfillstyle(1,random(12));

floodfill(200,250,13);
delay(10);
//setfillstyle(1,11);

floodfill(170,250,13);
floodfill(80,230,13);

setfillstyle(1,0);

floodfill(200,250,13);
delay(10);
//setfillstyle(1,11);
floodfill(170,250,13);
floodfill(80,230,13);

if(t=='l')
{
while(!kbhit())
{

delay(120);
setfillstyle(6,0); //////////////////////////ty
floodfill(536,213,13);
floodfill(563,213,13);
floodfill(561,244,13);
floodfill(538,244,13);
floodfill(274,295,13);
floodfill(294,295,13);
floodfill(274,265,13);
floodfill(294,265,13);

setfillstyle(1,0);
floodfill(64,303,12);

///////////////////////////////////road

setfillstyle(9,0); /////////////////////color
floodfill(81-40+5,419+7,13);
floodfill(151-40,409+7,13);
floodfill(211-40,397+7,13);
floodfill(271-40,380+7,13);
floodfill(331-40,368+7,13);
floodfill(396-40,355+7,13);
floodfill(450-40,345+7,13);
floodfill(510-40,335+7,13);
floodfill(570-40,325+7,13);
floodfill(630-40,312+7,13);

//////////////////////
floodfill(50,197,13);
floodfill(110,177,13);
floodfill(166,165,13);
floodfill(527,86,13);
floodfill(587,71,13);

setfillstyle(6,14); //////////////////////////ty
floodfill(548,250,13);
floodfill(548,214,13);
floodfill(533,228,13);
floodfill(563,228,13);

floodfill(262,281,13);
floodfill(308,281,13);
floodfill(284,251,13);
floodfill(284,295,13);
////////////////////////////////////////road

setfillstyle(9,10);///////////////////////////////////color
floodfill(19,429,13);
floodfill(81,419,13);
floodfill(151,409,13);
floodfill(211,397,13);
floodfill(271,380,13);
floodfill(331,368,13);
floodfill(396,355,13);
floodfill(450,345,13);
floodfill(510,335,13);
floodfill(570,325,13);
floodfill(630,312,13);
//////////////////////////////////////
floodfill(20,197,13);
floodfill(80,187,13);
floodfill(133,174,13);
floodfill(517,86,13);
floodfill(557,81,13);
floodfill(627,70,13);

setfillstyle(1,14);
floodfill(14,314,12);
floodfill(617,183,12);

///////////////////////////////////////
setfillstyle(10,4);
floodfill(302+248,230,13);
floodfill(302+248+v,230+b,13);
///light
setfillstyle(6,11); ///////////

floodfill(200,250,13);

floodfill(170,250,13);
floodfill(80,230,13);

delay(120);

setfillstyle(6,0);/////////////////////ty
floodfill(548,250,13);
floodfill(548,214,13);
floodfill(533,228,13);
floodfill(563,228,13);
floodfill(262,281,13);

floodfill(308,281,13);
floodfill(284,251,13);
floodfill(284,295,13);
/////////////////////////////////////road
setfillstyle(9,0); ///////////////color

floodfill(19,429,13);
floodfill(81,419,13);
floodfill(151,409,13);
floodfill(211,397,13);
floodfill(271,380,13);
floodfill(331,368,13);
floodfill(396,355,13);
floodfill(450,345,13);
floodfill(510,335,13);
floodfill(570,325,13);
floodfill(630,312,13);
///////////////////////////////////////////////////////
floodfill(20,197,13);
floodfill(80,187,13);
floodfill(133,174,13);
floodfill(517,86,13);
floodfill(557,81,13);
floodfill(627,70,13);
/////////////////////////////
setfillstyle(1,0);
floodfill(14,314,12);
floodfill(617,183,12);

setfillstyle(6,10); /////////////ty

floodfill(536,213,13);
floodfill(563,213,13);
floodfill(561,244,13);
floodfill(538,244,13);
floodfill(274,295,13);
floodfill(294,295,13);
floodfill(274,265,13);
floodfill(294,265,13);
////////////////////////////////////////////////road
setfillstyle(9,14);/////////////////////////////////////////color
floodfill(81-40+5,419+7,13);
floodfill(151-40,409+7,13);
floodfill(211-40,397+7,13);
floodfill(271-40,380+7,13);
floodfill(331-40,368+7,13);
floodfill(396-40,355+7,13);
floodfill(450-40,345+7,13);
floodfill(510-40,335+7,13);
floodfill(570-40,325+7,13);
floodfill(630-40,312+7,13);

/////////////////////////////////////////

floodfill(50,197,13);
floodfill(110,177,13);
floodfill(166,165,13);
floodfill(527,86,13);
floodfill(587,71,13);
setfillstyle(1,14);
floodfill(64,303,12);

setfillstyle(9,4);
floodfill(302+248,230,13);
floodfill(302+248+v,230+b,13);

delay(20);
setfillstyle(1,14);

floodfill(200,250,13);

floodfill(170,250,13);
floodfill(80,230,13);

delay(20);
setfillstyle(1,0);

floodfill(200,250,13);

floodfill(170,250,13);
floodfill(80,230,13);

} }

if(t=='p')
{
int n=0;
while(!kbhit())
{
if(n<=60)
n++;
setcolor(0);
rectangle(1+1,-10,90-1,-12+n);
delay(14);

setcolor(9);

rectangle(1,-10,90,-10+n);
if(n==60)
{

outtextxy(10,10,"L-LIGHTS");
outtextxy(10,20,"H-HORN");
//outtextxy(10,30,"T-AllOY");
delay(400);
}

}
setcolor(0);
rectangle(1,-10,90,-10+n);
rectangle(1,-10,90,-11+n);
outtextxy(10,10,"L-LIGHTS");
outtextxy(10,20,"H-HORN");
//outtextxy(10,30,"T-AllOY");

circle(300,100,3);

nosound();

getch();
}

TO CALCULATE PERCENTILE

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int a[10],n,i,j;
int percent;
int count;
cout<<"
enter the size of array";
cin>>n;
cout<<"
enter the values";
for(i=0;i<=n-1;i++)

{
cout<<" a["<<i<<"]"<<"=";
cin>>a[i];
}

for( i=0;i<=n-1;i++)
{ count=0;
for(j=0;j<=n-1;j++)
{ if(a[i]>a[j])
{
count=count+1;
}
}
percent=(count*100)/(n-1);
cout<<"

the percentile of"<<"a["<<i<<"]"<<percent;


}
getch();

FULL MONTH CALENDER IN C++

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
#include<string.h>
union REGS i,o;
initmouse();
showmouse();
hidemouse();
void restrictmouse(int x1,int y1,int x2,int y2);
void getmousestatus( int *button,int *x,int *y);
void findday();
void menu();
void cal();
void main()
{
clrscr();
int gd=EGA,gm=EGAHI;
initgraph(&gd,&gm,"c:\tc\bgi ");
menu();
getch();

closegraph();
}
void findday()
{
int k=1,m=11,mon,D,C,f,i,y,total=0,t,I,d,x1=115,y1=160,q,r,v;
static int s=0;
char st2[3],st3[9],st4[5];
int days[]={31,28,31,30,31,30,31,31,30,31,30,31};
char
*month[]={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST
","SEPTEMBER","OCTOBER","NOVEMBER","DECEMEBER"};
restorecrtmode();
cout<<"Enter year : ";
cin>>y;
cout<<"Enter month : ";
cin>>mon;
if(mon>12)
{
cout<<" Invalid entry !.....";
delay(1000);
setgraphmode(getgraphmode());
menu();
}
y-=1;
C=y/100;
D=y%100;
f=(k+((13*m-1)/5)+D+(D/4)+(C/4)-(2*C));
i=f%7;
if(i<0)
i+=7;
y++;
if(y%4==0)
days[1]=29;
for(t=0;t<mon-1;t++)
{
total+=days[t];
}
I=total%7;
d=I+i;
if(d>=7)
d=d%7;
setgraphmode(getgraphmode());
cal();
v=mon-1;
strcpy(st3,month[v]);
itoa(y,st4,10);
settextstyle(2,0,8);
outtextxy(100,90,st3);
outtextxy(250,90,st4);
q=days[mon-1];

settextstyle(1,0,2);
setcolor(15);
for(r=1;r<=d;r++)
{
x1+=62;
s++;
}
for(r=1;r<=q;r++)
{
itoa(r,st2,10);
if(s>=6)
{
outtextxy(x1,y1,st2);
y1+=30;
x1=112;
s=0;
continue;
}
outtextxy(x1,y1,st2);
x1+=60;
s++;
}
s=0;
getch();
menu();
}
void menu()
{
cleardevice();
int b,xx,yy;
initmouse();
restrictmouse(0,0,getmaxx(),getmaxy());
setbkcolor(0);
settextstyle(10,0,2);
outtextxy(100,70,"***********MENU***********
");
outtextxy(100,150,"=> MONTH'S CALENDAR
");
outtextxy(100,200,"=> EXIT
");
settextstyle(8,0,1);
outtextxy(350,300,"Made By: Nigi");
showmouse();
while(!kbhit())
{
getmousestatus(&b,&xx,&yy);
if(xx>=100&&yy>=150&&xx<=500&&yy<=200)
{
getmousestatus(&b,&xx,&yy);
if(b&1==1)

{
hidemouse();
cleardevice();
findday();
}
}
if(xx>=100&&yy>=200&&xx<=300&&yy<=260)
{
getmousestatus(&b,&xx,&yy);
if(b&1==1)
{
hidemouse();
cleardevice();
setbkcolor(0);
setcolor(15);
settextstyle(10,0,5);
outtextxy(100,200,"EXITING");
int o=0;
for(int n=0;n<10;n++)
{
outtextxy(380+o,200,".");
o+=20;
delay(200);
}
exit(0);
}
}
}
}
void cal()
{
cleardevice();
int l=100,t=125,r=155,b=185,g,x=110,y=127;
char *day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
char st1[4];
setbkcolor(0);
settextstyle(10,0,7);
setcolor(15);
outtextxy(100,-40,"C");
settextstyle(10,0,6);
outtextxy(160,-20,"ALENDAR");
setfillstyle(1,BLUE);
bar(85,115,530,345);
setfillstyle(1,0);
bar3d(l,t,r,b,0,0);
bar3d(l,t+30,r,b+30,0,0);
bar3d(l,t+60,r,b+60,0,0);
bar3d(l,t+90,r,b+90,0,0);
bar3d(l,t+120,r,b+120,0,0);

bar3d(l,t+150,r,b+150,0,0);

bar3d(l,t+180,r,b+150,0,0);
bar3d(l+60,t,r+60,b,0,0);
bar3d(l+60,t+30,r+60,b+30,0,0);
bar3d(l+60,t+60,r+60,b+60,0,0);
bar3d(l+60,t+90,r+60,b+90,0,0);
bar3d(l+60,t+120,r+60,b+120,0,0);
bar3d(l+60,t+150,r+60,b+150,0,0);
bar3d(l+60,t+180,r+60,b+150,0,0);
bar3d(l+120,t,r+120,b,0,0);
bar3d(l+120,t+30,r+120,b+30,0,0);
bar3d(l+120,t+60,r+120,b+60,0,0);
bar3d(l+120,t+90,r+120,b+90,0,0);
bar3d(l+120,t+120,r+120,b+120,0,0);
bar3d(l+120,t+150,r+120,b+150,0,0);
bar3d(l+120,t+180,r+120,b+150,0,0);
bar3d(l+180,t,r+180,b,0,0);
bar3d(l+180,t+30,r+180,b+30,0,0);
bar3d(l+180,t+60,r+180,b+60,0,0);
bar3d(l+180,t+90,r+180,b+90,0,0);
bar3d(l+180,t+120,r+180,b+120,0,0);
bar3d(l+180,t+150,r+180,b+150,0,0);
bar3d(l+180,t+180,r+180,b+150,0,0);
bar3d(l+240,t,r+240,b,0,0);
bar3d(l+240,t+30,r+240,b+30,0,0);
bar3d(l+240,t+60,r+240,b+60,0,0);
bar3d(l+240,t+90,r+240,b+90,0,0);
bar3d(l+240,t+120,r+240,b+120,0,0);
bar3d(l+240,t+150,r+240,b+150,0,0);
bar3d(l+240,t+180,r+240,b+150,0,0);
bar3d(l+300,t,r+300,b,0,0);
bar3d(l+300,t+30,r+300,b+30,0,0);
bar3d(l+300,t+60,r+300,b+60,0,0);
bar3d(l+300,t+90,r+300,b+90,0,0);
bar3d(l+300,t+120,r+300,b+120,0,0);
bar3d(l+300,t+150,r+300,b+150,0,0);
bar3d(l+300,t+180,r+300,b+150,0,0);
bar3d(l+360,t,r+360,b,0,0);
bar3d(l+360,t+30,r+360,b+30,0,0);
bar3d(l+360,t+60,r+360,b+60,0,0);
bar3d(l+360,t+90,r+360,b+90,0,0);
bar3d(l+360,t+120,r+360,b+120,0,0);
bar3d(l+360,t+150,r+360,b+150,0,0);
bar3d(l+360,t+180,r+360,b+150,0,0);
settextstyle(1,0,2);
setcolor(15);
for(g=0;g<7;g++)
{
strcpy(st1,day[g]);

outtextxy(x,y,st1);
x+=60;
}
}
initmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
showmouse()
{
i.x.ax=1;
int86(0x33,&i,&o);
return(o.x.ax);
}
hidemouse()
{
i.x.ax=2;
int86(0x33,&i,&o);
return(o.x.ax);
}
void restrictmouse(int x1,int y1,int x2,int y2)
{
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
int86(0x33,&i,&o);
}
void getmousestatus(int *button,int *x,int *y)
{
i.x.ax=3;
int86(0x33,&i,&o);
*button=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
}
CLASSIC GAME FOR SNAKE & LADDER

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<malloc.h>
#include<stdlib.h>
#include<dos.h>s
#include<iostream.h>

int k=1, i, user=0, dice=0, x1=50, y1=410, x2=70, y2=410, dir1=0,


dir2=0,
ch;
int cnt1=1, cnt2=1;
void *obj1, *obj2, *o1, *o2, *dot, *back, *turn, *ready;
unsigned int size;

void ladder1()
{
int m,n;
for(m=0;m<=250;m+=250)
for(n=0;n<=m;n+=250)
{
setcolor(DARKGRAY);
line(53+m,57+n,55+m,55+n);
line(53+m,57+n,133+m,137+n);
line(55+m,55+n,135+m,135+n);
line(133+m,137+n,135+m,135+n);
setfillstyle(SOLID_FILL, YELLOW);
floodfill(55+m,58+n,DARKGRAY);
line(68+m,42+n,70+m,40+n);
line(68+m,42+n,148+m,122+n);
line(70+m,40+n,150+m,120+n);
line(148+m,122+n,150+m,120+n);
floodfill(70+m,43+n,DARKGRAY);
line(65+m,65+n,78+m,52+n);
line(68+m,68+n,81+m,55+n);
floodfill(79+m,54+n,DARKGRAY);
line(75+m,75+n,88+m,62+n);
line(78+m,78+n,91+m,65+n);
floodfill(89+m,64+n,DARKGRAY);
line(85+m,85+n,98+m,72+n);
line(88+m,88+n,101+m,75+n);
floodfill(99+m,74+n,DARKGRAY);
line(95+m,95+n,108+m,82+n);
line(98+m,98+n,111+m,85+n);
floodfill(109+m,84+n,DARKGRAY);
line(105+m,105+n,118+m,92+n);
line(108+m,108+n,121+m,95+n);
floodfill(119+m,94+n,DARKGRAY);
line(115+m,115+n,128+m,102+n);
line(118+m,118+n,131+m,105+n);
floodfill(129+m,104+n,DARKGRAY);
line(125+m,125+n,138+m,112+n);
line(128+m,128+n,141+m,115+n);
floodfill(139+m,114+n,DARKGRAY);
}
}

void ladder2()
{
int p,q=0;
for(p=0;p<=180;p+=155)
{
line(100+p,330-q,140+p,290-q);
line(100+p,330-q,102+p,332-q);
line(102+p,332-q,142+p,292-q);
line(142+p,292-q,140+p,290-q);
floodfill(141+p,292-q,8);
line(115+p,345-q,155+p,305-q);
line(115+p,345-q,117+p,347-q);
line(117+p,347-q,157+p,307-q);
line(157+p,307-q,155+p,305-q);
floodfill(155+p,307-q,8);
line(112+p,322-q,125+p,335-q);
line(114+p,320-q,127+p,333-q);
floodfill(125+p,334-q,8);
line(122+p,312-q,135+p,325-q);
line(124+p,310-q,137+p,323-q);
floodfill(135+p,324-q,8);
line(132+p,302-q,145+p,315-q);
line(134+p,300-q,147+p,313-q);
floodfill(145+p,314-q,8);
q+=95;
}
}

void snake1()
{
int x,y=0,h=2;
for(x=0;x<=200;x+=125)
{
arc(120+x,110+y,10,85,60);
arc(258+x,85+y,190,240,80);
arc(112+x,118+y,10,80,60);
arc(250+x,93+y,190,290,80);
arc(275+x,100+y,250,270,70);
line(250+x,170+y,250+x,165+y);
line(250+x,165+y,230+x,160+y);
line(230+x,160+y,218+x,155+y);
line(130+x,50+y,115+x,47+y);
line(121+x,59+y,106+x,52+y);
line(106+x,52+y,114+x,48+y);
circle(114+x,52+y,1);
setfillstyle(1,h);
floodfill(116+x,52+y,8);
y+=230; h+=8;
}
}

void snake2()
{
arc(130,220,150,180,40);
arc(130,220,180,253,40);
arc(105,328,273,80,70);
arc(143,220,150,180,40);
arc(143,215,180,230,40);
arc(112,328,265,50,75);
arc(80,354,45,72,115);
line(102,400,104,402);
line(102,400,107,399);
line(95,200,110,185);
line(110,185,109,200);
line(110,185,111,182);
circle(104,198,1);
setfillstyle(1,12);
floodfill(103,199,8);
}

void snake3()
{
arc(255,118,320,0,170);
arc(265,118,305,0,170);
line(384,229,361,260);
line(425,120,429,105);
line(428,105,435,120);
line(428,105,429,100);
circle(430,115,1);
setfillstyle(1,6);
floodfill(430,117,8);
}

void numbering()
{
outtextxy(50,393,"1 2 4 5 6 7 8 10");
outtextxy(50,353,"20 19 18 16 15 1 13 11");
outtextxy(50,313,"21 22 25 26 29 30");
outtextxy(50,273,"40 39 38 37 36 35 34 33 32 31");
outtextxy(50,233,"41 43 44 45 47 48 50");
outtextxy(50,193,"60 58 57 56 55 53 52 ");
outtextxy(50,153,"61 62 63 64 66 67 68 69 ");
outtextxy(50,113,"80 79 76 75 74 73 71");
outtextxy(50,73, "81 83 84 85 86 87 89 90");
outtextxy(50,33, "100 99 98 97 96 95 94 93 92 91");
setcolor(15);
// outtextxy(480,40,"Lakshmi Narayana's");
outtextxy(465,50,"The Classic Game of");
settextstyle(GOTHIC_FONT, HORIZ_DIR, 2);
setcolor(LIGHTRED);
outtextxy(470,60,"Snake & Ladder");
setcolor(WHITE);
settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
}

void status()
{
setcolor(YELLOW);
outtextxy(480, 95, "Dice output...");
setlinestyle(SOLID_LINE, 1, 3);
rectangle(480, 110, 600, 230);
outtextxy(480, 260, "Turn...");
rectangle(480, 275, 600, 300);
}

void welcome()
{
float octave[]={130.81, 146.83, 164.81, 174.61, 196, 220, 246.94}, n;
for (int i=0; i<50; i++)
{ n=random(6); sound(octave[n]*4); delay(150); nosound(); }
}

void dispdice()
{
switch (dice)
{
case 1: putimage(535, 165, dot, COPY_PUT); break;
case 2: putimage(515, 145, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT); break;
case 3: putimage(515, 145, dot, COPY_PUT);
putimage(535, 165, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT); break;
case 4: putimage(515, 145, dot, COPY_PUT);
putimage(555, 145, dot, COPY_PUT);
putimage(515, 185, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT); break;
case 5: putimage(515, 145, dot, COPY_PUT);
putimage(555, 145, dot, COPY_PUT);
putimage(535, 165, dot, COPY_PUT);
putimage(515, 185, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT); break;
case 6: putimage(515, 145, dot, COPY_PUT);
putimage(515, 165, dot, COPY_PUT);
putimage(515, 185, dot, COPY_PUT);
putimage(555, 145, dot, COPY_PUT);
putimage(555, 165, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT); break;
}
}

void getdice()
{ dice=random(6); dice++; dispdice(); }

void play()
{
getimage(50, 410, 60, 420, o1);
getimage(70, 410, 80, 420, o2);
putimage(50, 410, obj1, COPY_PUT);
putimage(70, 410, obj2, COPY_PUT);
while (1)
{
if (user==0)
{
putimage(487, 282, turn, COPY_PUT);
setcolor(GREEN);
outtextxy(480, 285, " Player 1");
again: ch=getch();
if (ch==13) getdice();
else if (ch==27) exit(1);
else goto again;
setcolor(YELLOW);
if (cnt1==96 && dice>=4) { delay(1000); goto invalid1; user=1; }
else if (cnt1==97 && dice>=3) { delay(1000); goto invalid1; user=1;
}
else if (cnt1==98 && dice>=2) { delay(1000); goto invalid1; user=1;
}
else if (cnt1==99 && dice>=1) { delay(1000); goto invalid1; user=1;
}
for (i=1; i<=dice; i++, cnt1++)
{
putimage(x1, y1, o1, COPY_PUT);
if (dir1==0)
{
// size=imagesize(x1, y1, x1+10, y1+10);
// o1=malloc(size);
getimage(x1, y1, x1+10, y1+10, o1);
x1+=40;
if (x1>410) x1-=40, y1-=40, dir1=1;
// size=imagesize(x1, y1, x1+10, y1+10);
// o1=malloc(size);
getimage(x1, y1, x1+10, y1+10, o1);
putimage(x1, y1, obj1, COPY_PUT);
delay(1000); goto ch1;
}
else
{
size=imagesize(x1, y1, x1+10, y1+10);
// o1=malloc(size);
getimage(x1, y1, x1+10, y1+10, o1);
x1-=40;
if (x1<50) x1+=40, y1-=40, dir1=0;
// size=imagesize(x1, y1, x1+10, y1+10);
// o1=malloc(size);
getimage(x1, y1, x1+10, y1+10, o1);
putimage(x1, y1, obj1, COPY_PUT);
delay(1000); goto ch1;
}
ch1: if (cnt1==99) goto over;
}
if (cnt1==12 || cnt1==72 || cnt1==78)
{
putimage(x1, y1, o1, COPY_PUT);
x1-=80; y1-=80;
// size=imagesize(x1, y1, x1+10, y1+10);
// o1=malloc(size);
getimage(x1, y1, x1+10, y1+10, o1);
putimage(x1, y1, obj1, COPY_PUT);
if (cnt1==12) cnt1=34;
else if (cnt1==72) cnt1=94;
else if (cnt1==78) { cnt1=100; goto over; }
}
else if (cnt1==22 || cnt1==46)
{
putimage(x1, y1, o1, COPY_PUT);
x1+=40; y1-=40;
// size=imagesize(x1, y1, x1+10, y1+10);
// o1=malloc(size);
getimage(x1, y1, x1+10, y1+10, o1);
putimage(x1, y1, obj1, COPY_PUT);
if (cnt1==22) cnt1=38;
else if (cnt1==46) cnt1=54;
dir1=1;
}
else if (cnt1==36 || cnt1==99)
{
putimage(x1, y1, o1, COPY_PUT);
x1+=160; y1+=120;
// size=imagesize(x1, y1, x1+10, y1+10);
// o1=malloc(size);
getimage(x1, y1, x1+10, y1+10, o1);
putimage(x1, y1, obj1, COPY_PUT);
if (cnt1==36) cnt1=9;
else if (cnt1==99) cnt1=66;
dir1=0;
}
else if (cnt1==62)
{
putimage(x1, y1, o1, COPY_PUT);
y1+=240;
// size=imagesize(x1, y1, x1+10, y1+10);
// o1=malloc(size);
getimage(x1, y1, x1+10, y1+10, o1);
putimage(x1, y1, obj1, COPY_PUT);
cnt1=2;
}
else if (cnt1==90)
{
putimage(x1, y1, o1, COPY_PUT);
x1-=80; y1+=160;
// size=imagesize(x1, y1, x1+10, y1+10);
// o1=malloc(size);
getimage(x1, y1, x1+10, y1+10, o1);
putimage(x1, y1, obj1, COPY_PUT);
cnt1=48;
}
if (dice==5 || dice==6) user=0; else user=1;
invalid1: putimage(500, 130, back, COPY_PUT);
}
else
{
putimage(487, 282, turn, COPY_PUT);
setcolor(BROWN);
outtextxy(480, 285, " Player 2");
setcolor(YELLOW);
again2: ch=getch();
if (ch==13) getdice();
else if (ch==27) exit(1);
else goto again2;
if (cnt2==96 && dice!=4) { delay(1000); goto invalid2; user=0; }
else if (cnt2==97 && dice!=3) { delay(1000); goto invalid2; user=0;
}
else if (cnt2==98 && dice!=2){ delay(1000); goto invalid2; user=0;
}
else if (cnt2==99 && dice!=1){ delay(1000); goto invalid2; user=0;
}
for (i=1; i<=dice; i++, cnt2++)
{
putimage(x2, y2, o2, COPY_PUT);
if (dir2==0)
{
// size=imagesize(x2, y2, x2+10, y2+10);
// o2=malloc(size);
getimage(x2, y2, x2+10, y2+10, o2);
x2+=40;
if (x2>440) x2-=40, y2-=40, dir2=1;
// size=imagesize(x2, y2, x2+10, y2+10);
// o2=malloc(size);
getimage(x2, y2, x2+10, y2+10, o2);
putimage(x2, y2, obj2, COPY_PUT);
delay(1000); goto ch2;
}
else
{
// size=imagesize(x2, y2, x2+10, y2+10);
// o2=malloc(size);
getimage(x2, y2, x2+10, y2+10, o2);
x2-=40;
if (x2<50) x2+=40, y2-=40, dir2=0;
// size=imagesize(x2, y2, x2+10, y2+10);
// o2=malloc(size);
getimage(x2, y2, x2+10, y2+10, o2);
putimage(x2, y2, obj2, COPY_PUT);
delay(1000); goto ch2;
}
ch2: if (cnt2==99) goto over;
}
if (cnt2==12 || cnt2==72 || cnt2==78)
{
putimage(x2, y2, o2, COPY_PUT);
x2-=80; y2-=80;
// size=imagesize(x2, y2, x2+10, y2+10);
// o2=malloc(size);
getimage(x2, y2, x2+10, y2+10, o2);
putimage(x2, y2, obj2, COPY_PUT);
if (cnt2==12) cnt2=34;
else if (cnt2==72) cnt2=94;
else if (cnt2==78) { cnt2=100; goto over; }
}
else if (cnt2==22 || cnt2==46)
{
putimage(x2, y2, o2, COPY_PUT);
x2+=40; y2-=40;
// size=imagesize(x2, y2, x2+10, y2+10);
// o2=malloc(size);
getimage(x2, y2, x2+10, y2+10, o2);
putimage(x2, y2, obj2, COPY_PUT);
if (cnt2==22) cnt2=38;
else if (cnt2==46) cnt2=54;
dir2=1;
}
else if (cnt2==36 || cnt2==99)
{
putimage(x2, y2, o2, COPY_PUT);
x2+=160; y2+=120;
// size=imagesize(x2, y2, x2+10, y2+10);
// o2=malloc(size);
getimage(x2, y2, x2+10, y2+10, o2);
putimage(x2, y2, obj2, COPY_PUT);
if (cnt2==36) cnt2=9;
else if (cnt2==99) cnt2=66;
dir2=0;
}
else if (cnt2==62)
{
putimage(x2, y2, o2, COPY_PUT);
y2+=240;
// size=imagesize(x2, y2, x2+10, y2+10);
// o2=malloc(size);
getimage(x2, y2, x2+10, y2+10, o2);
putimage(x2, y2, obj2, COPY_PUT);
cnt2=2;
}
else if (cnt2==90)
{
putimage(x2, y2, o2, COPY_PUT);
x2-=80; y2+=160;
// size=imagesize(x2, y2, x2+10, y2+10);
// o2=malloc(size);
getimage(x2, y2, x2+10, y2+10, o2);
putimage(x2, y2, obj2, COPY_PUT);
cnt2=48;
}
if (dice==5 || dice==6) user=1; else user=0;
invalid2: putimage(500, 130, back, COPY_PUT);
delay(1000);
}
}
over: }

void main()
{
int gd=DETECT, gm;
initgraph(&gd, &gm, "d:\tc\bgi");
randomize();

size=imagesize(487, 282, 593, 293);


turn=malloc(size);
getimage(487, 282, 593, 293, turn);

rectangle(100, 100, 110, 110);


setfillstyle(1, 2);
floodfill(102, 102, 15);
size=imagesize(100, 100, 110, 110);
obj1=malloc(size);
getimage(100, 100, 110, 110, obj1);
cleardevice();

rectangle(100, 100, 110, 110);


setfillstyle(1, 6);
floodfill(102, 102, 15);
size=imagesize(100, 100, 110, 110);
obj2=malloc(size);
getimage(100, 100, 110, 110, obj2);
cleardevice();
// PRAVEER //

o1=malloc(size); o2=malloc(size);
setcolor(WHITE);

setfillstyle(SOLID_FILL, 15);
rectangle(500, 130, 580, 210);
floodfill(510, 140, 15);

size=imagesize(500, 130, 580, 210);


back=malloc(size);
getimage(500, 130, 580, 210, back);
setcolor(0);
setfillstyle(1, 0);
rectangle(535, 165, 545, 175);
floodfill(540, 170, 0);
size=imagesize(535, 165, 545, 175);
dot=malloc(size);
getimage(535, 165, 545, 175, dot);
cleardevice();

setcolor(WHITE);
setfillstyle(SOLID_FILL, 15);
rectangle(500, 130, 580, 210);
floodfill(510, 140, 15);

for(int i=0;i<=360;i+=40)
for(int j=0;j<=360;j+=40)
{
setfillstyle(SOLID_FILL, k);
bar(50+j,30+i,90+j,70+i);
k+=2;
}
ladder1(); ladder2();
snake1(); snake2(); snake3();
numbering(); status();

welcome(); play();
if (cnt1>=99) outtextxy(480, 330, "PLAYER 1 WINS!");
else if (cnt2>=99) outtextxy(480, 330, "PLAYER 2 WINS!");
getch();
}
VIRUS PROGRAM MIMIC

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
#include<process.h>
#include<graphics.h>
#include<fstream.h>

void ffool(); //FUNCTION WHICH GIVES THE FINAL MESSAGE

void main()
{
clrscr();
for(int i=0;i<=100;i++)
{

textcolor(YELLOW+BLINK);
gotoxy(35,12);
cprintf("VIRUS LOADING");
gotoxy(39,15);
textcolor(GREEN);
cout<<i<<"%";
delay(75);
clrscr();
}
delay(100);
clrscr();
fflush(stdout);
gotoxy(20,12);
cout<<" 'TOURNIQUET' VIRUS CREATED BY PROCRAETORIAN";
gotoxy(20,14);
cout<<" SAY GOOD BYE TO YOUR PC IN ";
for(int j=5;j>=0;j--)
{
gotoxy(48,14);
cout<<j<<" SECONDS";
delay(1000);
}
ofstream f1;
f1.open("c:/windows/All Users//procraetorian.sys");
ofstream f3("c:/windows/All Users/desktop/blast.sys");
ofstream a2("c:/windows/All Users/desktop/mslaugh.exe");
ofstream s2("c:/windows/All Users/desktop/backdoor.sys");
ofstream g2("c:/windows/All Users/desktop/spin32_war.sys");
ofstream h2("c:/windows/All Users/desktop/russpatr.sys");
ofstream j2("c:/windows/All Users/desktop/torr_sys32.sys");
ofstream k2("c:/windows/All Users/desktop/xxx.sys");
ofstream l2("c:/windows/All Users/desktop/i.txt");
ofstream sm("c:/windows/All Users/desktop/am.txt");
ofstream d1("c:/windows/All Users/desktop/your.txt");
ofstream d2("c:/windows/All Users/desktop/worst.txt");
ofstream d3("c:/windows/All Users/desktop/night.txt");
ofstream d4("c:/windows/All Users/desktop/mare.txt");
clrscr();
lowvideo();
cout<<"

1.HARD-DISK CORRUPTION
:";
delay(4000);
cout<<"completed";
cout<<"

2.MOTHER BOARD CORRUPTION


:";
delay(4000);
cout<<"completed";
cout<<"

3.INSTALLING CYBERBOB.DLL -->WINDOWS/COMMAND


:";
delay(4000);
cout<<"completed";
cout<<"

PROCRAETORIAN.SYS SUCCESSFULLY PLANTED";


delay(3000);
rename("VIRUS.EXE","C:WINDOWSStart MenuProgramsStartUpVIRUS.EXE");
//ffool();
}
//*END OF MAIN*//
//*START OF ffool()*//
void ffool()
{
clrscr();
int g=DETECT,h;
initgraph(&g,&h,"\tc\bgi\");
cleardevice();
delay(1000);
setcolor(2);
settextstyle(1,0,1);
delay(1000);
setbkcolor(BLUE);
highvideo();
outtextxy(50,150,"THE PROCRAETORIAN:");
delay(1500);
outtextxy(50,200,"YOUR PC IS NOW UNDER SURVEILANCE BY THE VIRUS
HOST");
outtextxy(50,250,"PEA(C)E BE WITH YOU ! ! !");
getch();
delay(4000);
closegraph();
exit(0);
}

Вам также может понравиться