Computer Science Project's - Praveer

download Computer Science Project's - Praveer

of 60

Transcript of Computer Science Project's - Praveer

  • 8/9/2019 Computer Science Project's - Praveer

    1/60

    CUMPUTERSCIENCE

    PROJECT'S

    - PRAVEER NARAVRIYA

  • 8/9/2019 Computer Science Project's - Praveer

    2/60

    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.

  • 8/9/2019 Computer Science Project's - Praveer

    3/60

    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 GMAILACCOUNTS

    4) STUDENT MGM

    5) CLASSIC GAME OF SNAKE & LADDER

    6) VIRUS JOKE PROGRAM

  • 8/9/2019 Computer Science Project's - Praveer

    4/60

    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.DescriptionErrNum = Err.Number

    BeepMsgBox "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

  • 8/9/2019 Computer Science Project's - Praveer

    5/60

    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 creatingDataSourceName(dsn) in this example*/

    /* Steps to use this example:* go to ms-access and make a table called "student_base" and give it afile name student_base.mdb* 1. Go to Control Panel

    2. Click on Administrative Tools(windows 2000/xp), Click onODBC(win98)

    3. click on ODBC4. Then , you will see a ODBC dialog box. Click on UserDSn5. Click on Add Button6. Select Microsoft Access Driver(*.mdb) driver and click on finish7. Give a Data Source Name : student_base8. Then Click on Select9. Browse on the database name you have created and click

    it:student_base.mdb is a database file where all datawill 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; //buttonsprivate JTextField tf1,tf2;//textfieldsprivate JLabel lblname,lbladd,lblmsg; //labels

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

    public AddNewStudent() //constructor{//initializing buttonsbtnok = new JButton("OK");btnok.addActionListener(this);btnexit = new JButton("Exit");

  • 8/9/2019 Computer Science Project's - Praveer

    6/60

    btnexit.addActionListener(this);btnaddnew = new JButton("AddNew");

    btnaddnew.addActionListener(this);

    //initializing textfieldstf1 = 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 flowlayoutp1.setLayout(new FlowLayout());

    p1.add(btnok);p1.add(btnexit);p1.add(btnaddnew);

    //adding lblmsg to panel p3p3.add(lblmsg);

    //adding both the panels to new panel,psouth//settin layout 2:1psouth.setLayout(new GridLayout(2,1));psouth.add(p3);psouth.add(p1);

    //adding label and textfields to panel p2p2.setLayout(new GridLayout(3,1));

    //setting line and titled border for panel p2p2.setBorder(BorderFactory.createLineBorder(Color.red));p2.setBorder(BorderFactory.createTitledBorder("Enter Your

    Details"));p2.add(lblname);p2.add(tf1);p2.add(lbladd);p2.add(tf2);

  • 8/9/2019 Computer Science Project's - Praveer

    7/60

    //adding panel to containerthis.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 handlingpublic 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 wellif((tf1.getText().equals("")&&(tf2.getText().equals("")))){lblmsg.setText("Enter your details ");lblmsg.setForeground(Color.magenta);

    }

    else{

    try

    { //loading the driverClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    //connection object created using DriverManager class//student_base is the name of the databaseConnection connect =

    DriverManager.getConnection("jdbc:odbc:student_base");

  • 8/9/2019 Computer Science Project's - Praveer

    8/60

    //creating prepared statement object pstm so that query can besent to database

    pstm=connect.prepareStatement("insert into student_basevalues(?,?)");

    pstm.setString(1,tf1.getText());pstm.setString(2,tf2.getText());//execute method to execute the querypstm.executeUpdate();lblmsg.setText("Details have been added to database");

    //closing the prepared statement and connection objectpstm.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 toenternext record

    if(e.getSource()==btnaddnew){tf1.setText("");tf2.setText("");

    }

    if(e.getSource()==btnexit){System.exit(1);

    }}}

  • 8/9/2019 Computer Science Project's - Praveer

    9/60

    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 = "[email protected]";private static final String SSL_FACTORY ="javax.net.ssl.SSLSocketFactory";private static final String[] sendTo = {"[email protected]","[email protected]"};

    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;

  • 8/9/2019 Computer Science Project's - Praveer

    10/60

    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("[email protected]", "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 partMimeBodyPart messageBodyPart =new MimeBodyPart();

    //fill messagemessageBodyPart.setText("Hi");

    Multipart multipart = new MimeMultipart();multipart.addBodyPart(messageBodyPart);

  • 8/9/2019 Computer Science Project's - Praveer

    11/60

    // 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 messagemessage1.setContent(multipart);

    // Send the message

    Transport.send( message1 );}}

  • 8/9/2019 Computer Science Project's - Praveer

    12/60

    STUDENT MANAGEMENT

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

    public class menu extends Frame implementsWindowListener,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");

  • 8/9/2019 Computer Science Project's - Praveer

    13/60

    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)

  • 8/9/2019 Computer Science Project's - Praveer

    14/60

    {

    while(x>0 && y>0)

    {setSize(x,y);x=x-d;y=y-d;show();

    }System.out.println("mail me at [email protected]");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;

  • 8/9/2019 Computer Science Project's - Praveer

    15/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    16/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    17/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    18/60

    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 reportclass 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);

  • 8/9/2019 Computer Science Project's - Praveer

    19/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    20/60

    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;

  • 8/9/2019 Computer Science Project's - Praveer

    21/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    22/60

    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 databaseclass student extends Frame implements ActionListener,WindowListener

  • 8/9/2019 Computer Science Project's - Praveer

    23/60

    {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()

  • 8/9/2019 Computer Science Project's - Praveer

    24/60

    {//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);

  • 8/9/2019 Computer Science Project's - Praveer

    25/60

    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_sub5.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))

  • 8/9/2019 Computer Science Project's - Praveer

    26/60

    { dlg.dispose();}

    //CANCELif(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("");}

    //FINDif(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());

  • 8/9/2019 Computer Science Project's - Praveer

    27/60

    }

    //DELETEif(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());}

    //EDITif(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.getText()+",SUB3="+tf_sub3.getText()+",SUB4="+tf_sub4.getText()+",SUB5="+tf_sub5.getText()+",COLG='"+tf_colg.getText()+"' whereROLLNO="+tf_rollno.getText();st=con.createStatement();

  • 8/9/2019 Computer Science Project's - Praveer

    28/60

    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

    #include#include#include#include

    void main(){

    int gd=DETECT,gm;initgraph(&gd,&gm,"c:\tc\bgi");

    int c=12;

  • 8/9/2019 Computer Science Project's - Praveer

    29/60

    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);

    ///////////////////////// mirrorline(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);

    ////////////////////////////////sidemirrorline(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);

  • 8/9/2019 Computer Science Project's - Praveer

    30/60

    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;////////////////////////lowerline(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);

    //////////////////////frontellipse(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

  • 8/9/2019 Computer Science Project's - Praveer

    31/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    32/60

    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);

    ///////////////////lightsellipse(199,250,144,345,18,8);line(185,245,206,230);//setcolor(4);ellipse(223,234,340,110,8,5);

  • 8/9/2019 Computer Science Project's - Praveer

    33/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    34/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    35/60

    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);

    //2setcolor(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); //////////////////////////////////3k=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);

  • 8/9/2019 Computer Science Project's - Praveer

    36/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    37/60

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

    }

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

    delay(120);setfillstyle(6,0); //////////////////////////tyfloodfill(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); /////////////////////colorfloodfill(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); //////////////////////////tyfloodfill(548,250,13);

  • 8/9/2019 Computer Science Project's - Praveer

    38/60

    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);///////////////////////////////////colorfloodfill(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);///lightsetfillstyle(6,11); ///////////

    floodfill(200,250,13);

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

    delay(120);

    setfillstyle(6,0);/////////////////////tyfloodfill(548,250,13);floodfill(548,214,13);

  • 8/9/2019 Computer Science Project's - Praveer

    39/60

    floodfill(533,228,13);floodfill(563,228,13);floodfill(262,281,13);

    floodfill(308,281,13);floodfill(284,251,13);

    floodfill(284,295,13);/////////////////////////////////////roadsetfillstyle(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);////////////////////////////////////////////////roadsetfillstyle(9,14);/////////////////////////////////////////colorfloodfill(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);

  • 8/9/2019 Computer Science Project's - Praveer

    40/60

    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

  • 8/9/2019 Computer Science Project's - Praveer

    41/60

    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#include

    void main(){clrscr();int a[10],n,i,j;int percent;int count;cout>n;

  • 8/9/2019 Computer Science Project's - Praveer

    42/60

    cout

  • 8/9/2019 Computer Science Project's - Praveer

    43/60

    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();couty;coutmon;if(mon>12){

    cout

  • 8/9/2019 Computer Science Project's - Praveer

    44/60

    outtextxy(100,90,st3);outtextxy(250,90,st4);q=days[mon-1];

    settextstyle(1,0,2);

    setcolor(15);for(r=1;r=100&&yy>=150&&xx

  • 8/9/2019 Computer Science Project's - Praveer

    45/60

    {getmousestatus(&b,&xx,&yy);if(b&1==1)

    {hidemouse();cleardevice();findday();

    }}if(xx>=100&&yy>=200&&xx

  • 8/9/2019 Computer Science Project's - Praveer

    46/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    47/60

    for(g=0;g

  • 8/9/2019 Computer Science Project's - Praveer

    48/60

    CLASSIC GAME FOR SNAKE & LADDER

    #include#include#include#include#include#includes#include

    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

  • 8/9/2019 Computer Science Project's - Praveer

    49/60

    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

  • 8/9/2019 Computer Science Project's - Praveer

    50/60

    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 ");

  • 8/9/2019 Computer Science Project's - Praveer

    51/60

    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

  • 8/9/2019 Computer Science Project's - Praveer

    52/60

    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; i410) 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

  • 8/9/2019 Computer Science Project's - Praveer

    53/60

    {size=imagesize(x1, y1, x1+10, y1+10);

    // o1=malloc(size);getimage(x1, y1, x1+10, y1+10, o1);x1-=40;if (x1

  • 8/9/2019 Computer Science Project's - Praveer

    54/60

    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; i440) 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;

    }

  • 8/9/2019 Computer Science Project's - Praveer

    55/60

    else{

    // size=imagesize(x2, y2, x2+10, y2+10);// o2=malloc(size);

    getimage(x2, y2, x2+10, y2+10, o2);x2-=40;if (x2

  • 8/9/2019 Computer Science Project's - Praveer

    56/60

    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);

  • 8/9/2019 Computer Science Project's - Praveer

    57/60

    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=99) outtextxy(480, 330, "PLAYER 2 WINS!");getch();

    }

  • 8/9/2019 Computer Science Project's - Praveer

    58/60

    VIRUS PROGRAM MIMIC

    #include#include#include#include#include#include#include

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

    void main(){

    clrscr();for(int i=0;i

  • 8/9/2019 Computer Science Project's - Praveer

    59/60

    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

  • 8/9/2019 Computer Science Project's - Praveer

    60/60

    outtextxy(50,250,"PEA(C)E BE WITH YOU ! ! !");getch();delay(4000);closegraph();exit(0);

    }