Assingment File

download Assingment File

of 12

Transcript of Assingment File

  • 8/20/2019 Assingment File

    1/39

      0

  • 8/20/2019 Assingment File

    2/39

      1

    cknowledgement

    I express my deep gratitude and appreciation to those who agreed to

    participate in this project, for their time and courage in sharing their insights

     with a fledging student. It is to them I am most indebted, and I can only

    hope the product of our collaboration benefits each one as much as I

    benefited from the process.

    I thank my God for providing me with everything that I required in

    completing this project.

    I am highly indebted to the Teacher in Charge Mrs. Priyanka Upmanyu for

    her guidance and constant supervision as well as for providing necessary

    information regarding the assignment & also for her support in completing

    the project. Also, I thank Mr.H.P Singh, principal, K.V No.1 AFS for

    supporting me in completion of this project.

    I would like to express my gratitude towards my parents for their kind co-

    operation and encouragement which helped me in the completion of this

    project.

    My thanks and appreciations also go to my classmates in developing the

    project and to the people who have willingly helped me out with their

    abilities.

    ISHTA TRIPATHI

    Class XII – D (Commerce)

  • 8/20/2019 Assingment File

    3/39

      2

    Certificate

    This is to certify that Miss shta Tripathi of Class XII - D

    (Commerce) of Kendriya Vidyalaya had completed her assignment

    file under my supervision. She has taken proper care and shownutmost sincerity in the completion of the project. I certify that this

    project is up to my expectations and as per the guidelines issued by

    the CBSE.

    Mrs. Priyanka Upmanyu

    P.G.T Computer Science

  • 8/20/2019 Assingment File

    4/39

      3

    Declaration 

    I hereby declare that the assignment file submitted to Department of

    Computer Science and Informatics Practices, Kendriya Vidyalaya isprepared by us. All the coding is a result of only my personal efforts.

    ISHTA TRIPATHIClass XII – D (Commerce)

  • 8/20/2019 Assingment File

    5/39

      4

    Contents

    1. 

    Simple Java IDE Projects……..5-222.

     

    MySQL Queries…....…………23-28

    3. 

    Connectivity Programs………29-34

    4. 

    Html Pages……………………35-38

  • 8/20/2019 Assingment File

    6/39

      5

    Simple Java ide pplications

    1)  To display the no. of year, months and days as the input of no. of days

    given by the user.

    Coding:

    private void jButton1ActionPerformed(java.awt.event.ActionEvent 

    evt) { 

    String days= JOptionPane.showInputDialog("Enter No. of Days"); 

    int ds=Integer.parseInt(days); 

    int d =0, m=0, y=0; 

    y = ds/365; 

    m = (ds

     % 365)

     / 30;

     

    d = (ds %365) % 30; 

    String msg = ""+ds+" days are equivalent to \n"+y+" years "+m+" 

    months "+d+" days approx."; 

    JOptionPane.showMessageDialog(null, msg); Screen Shots:

  • 8/20/2019 Assingment File

    7/39

      6

    2) 

    A simple text editor that offers typing, copy, cut and paste features.

    Coding:

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

    ta.cut(); 

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

    ta.copy(); 

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

    ta.paste(); 

    Screen Shots:

    Figure 1 TextFigure 2 After Cut

    Figure 3 After Clicking Paste

  • 8/20/2019 Assingment File

    8/39

      7

    3) 

    Program to check whether the given no. is Palindrome or not.

    Coding:

    boolean testPalin(int n){ 

    int n1 = n, rev = 0; 

    int dig = 0; 

    while (n1>0){ 

    dig = n1 % 10; 

    rev = rev * 10 + dig; 

    n1 = n1 / 10;  } 

    if (n==rev) 

    return true; 

    else 

    return false; 

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

    int num = Integer.parseInt(tf1.getText()); 

    boolean result = testPalin(num); 

    if (result) 

    l2.setText(num+" is a Palindrome."); 

    else 

    l2.setText(num+" is NOT sa Palindrome."); 

    Screen Shots:

  • 8/20/2019 Assingment File

    9/39

      8

    4) 

    Design an application for bill calculation of a ice-cream parlor. The

     parlor offers three verities of ice-cream – vanilla, strawberry, chocolate.

    Vanilla icecream costs Rs. 30, Strawberry Rs. 35 and Chocolate Rs. 50. A

    customer can chose one or more ice-creams, with quantities more than

    one for each of the variety chosen. To calculate the bill parlor manager

    selects the appropriate check boxes according to the verities of ice-cream

    chosen by the customer and enter their respective quantities.

    Coding:

    int pv=20,ps=35,pc=45; 

    int q; 

    String error="Please enter a Valid Quantity."; 

    private void formWindowGainedFocus(java.awt.event.WindowEvent evt) { 

    tf1.setText(pv+""); 

    tf2.setText(ps+""); 

    tf3.setText(pc+""); 

    if (cb1.isSelected()==true) 

    tf11.setEditable(true); 

    if (cb2.isSelected()==true) 

    tf22.setEditable(true); 

    if (cb3.isSelected()==true) 

    tf33.setEditable(true); 

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

    int q=Integer.parseInt(tf111.getText()); 

    int w=Integer.parseInt(tf222.getText()); 

    int e=Integer.parseInt(tf333.getText()); 

    tf.setText(q+w+e+""); 

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

  • 8/20/2019 Assingment File

    10/39

      9

    cb1.setSelected(false); 

    cb2.setSelected(false); 

    cb3.setSelected(false); 

    tf11.setText(0+""); 

    tf11.setEditable(false); 

    tf111.setText(0+""); 

    tf22.setText(0+""); 

    tf22.setEditable(false); 

    tf222.setText(0+""); 

    tf33.setText(0+""); 

    tf33.setEditable(false); 

    tf333.setText(0+""); 

    tf.setText(0+""); 

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

    System.exit(0); 

    Screen Shots: 

    Figure 4 Basic Application Figure 5 Result

  • 8/20/2019 Assingment File

    11/39

      10

    5) 

    Regal Theater has computerized its ticketing system. The programmer

    has developed a GUI application in NetBeans as the given conditions,

    At the ticket counter, 3 types of tickets (box, balcony, general) at the rate

    of 200, 150 and 100 respectively are available. If the movie is tax free,

    then the total amount should be deducted by Rs. 25 per ticket.

    Coding:private void b1ActionPerformed(java.awt.event.ActionEvent evt) { 

    int n,amt,tamt,temp; 

    n=Integer.parseInt(tf2.getText()); 

    if (rb1.isSelected()==true){ 

    amt=n*200; 

    tf3.setText(""+amt);} 

    else if (rb2.isSelected()==true){

     

    amt=n*150; 

    tf3.setText(""+amt);} 

    else { 

    amt=n*100; 

    tf3.setText(""+amt);} 

    temp=Integer.parseInt(tf3.getText()); 

    if (cb.isSelected()==true){ 

    tamt=temp‐(n*25); 

    tf3.setText(""+tamt);} 

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

    tf1.setText(""); 

    tf2.setText(""); 

    tf3.setText(""); 

    cb.setSelected(false); 

    type_of_ticket.clearSelection(); 

  • 8/20/2019 Assingment File

    12/39

      11

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

    b2.doClick(); 

    System.exit(0); 

    Screen Shots:

  • 8/20/2019 Assingment File

    13/39

      12

    6) 

    Design an application which implements functionality by passgin

    arguments of the text fields by passing them into methods {calcSum(),

    calcAvg(), calcMax()}.

    Coding:

    float t; 

    public float

     CalcSum(float

     x,float

     y,float

     z){

     

    t=x+y+z; 

    return t; 

    public float CalcAvg(float p,float q,float r){ 

    t=(p+q+r)/3; 

    return t; 

    public float CalcMax(float i,float j,float k){ 

    if (i>j) 

    if (i>k) 

    return i; 

    else 

    return k; 

    else 

    if (j>k) 

    return j; 

    else 

    return k; 

    float dis; 

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

    float a,b,c; 

    a=Float.parseFloat(tf1.getText()); 

    b=Float.parseFloat(tf2.getText()); 

  • 8/20/2019 Assingment File

    14/39

      13

    c=Float.parseFloat(tf3.getText()); 

    dis=CalcSum(a,b,c);  // Method Call 

    ta.append("Sum: "+dis+"\n"); 

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

    float a,b,c;

     

    a=Float.parseFloat(tf1.getText()); 

    b=Float.parseFloat(tf2.getText()); 

    c=Float.parseFloat(tf3.getText()); 

    dis=CalcMax(a,b,c);  // Method Call 

    ta.append("Average: "+dis+"\n"); 

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

    float a,b,c; 

    a=Float.parseFloat(tf1.getText()); 

    b=Float.parseFloat(tf2.getText()); 

    c=Float.parseFloat(tf3.getText()); 

    dis=CalcMax(a,b,c);  // Method Call 

    ta.append("Maximum: "+dis+"\n\n");

     

    Screen Shots:

  • 8/20/2019 Assingment File

    15/39

      14

    7) 

    Write code for “add” button to add the text into the textarea “ta”

    depending upon the selection made by the user.

    Coding:

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

    if (rb1.isSelected()==true) 

    ta1.append("Male"+'\t'); 

    else if (rb2.isSelected()==true) 

    ta1.append("Female"+'\t'); 

    else if (rb3.isSelected()==true) 

    ta1.append("Other"+'\t'); 

    else{ 

    JOptionPane.showMessageDialog(null,"Please 

    Select 

    Your 

    Gender!"); 

    ta1.append("Not Entered"+'\t');} 

    String age= (String)cb1.getSelectedItem(); 

    int i=0; 

    int length= cb1.getItemCount(); 

    boolean exists = false; 

    for (;i

  • 8/20/2019 Assingment File

    16/39

      15

    gender.clearSelection(); 

    cb1.setSelectedIndex(‐1); 

    jl1.clearSelection(); 

    ta1.setText(""); 

    Screen Shots:

  • 8/20/2019 Assingment File

    17/39

      16

    8) 

    Check whether the password is “Student” or not. If not display an error.

    Coding:

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

    b1.doClick(0); 

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

    String pd,name; 

    name = tf.getText(); 

    pd= new String (pf.getPassword()); 

    if (pd.equals ("student")){ 

    tp1.setText("Welcome Back

     "+name+","+'\n'+"You

     have

     logged

     in 

    successfully."); 

    b2.setText("Proceed"); 

    d1.setVisible(true);} 

    else{ 

    JOptionPane.showMessageDialog(null,"Wrong Password"+'\n'+"Try 

    Again"); 

    pf.setText("");} 

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

    System.exit(0); 

    Screen Shots: 

  • 8/20/2019 Assingment File

    18/39

      17

    9) 

    Programme to swap two numbers input by user.

    Coding:

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

    Float a,b,c; 

    a=Float.parseFloat(tf1.getText()); 

    b=Float.parseFloat(tf2.getText()); 

    c=b; 

    b=a; 

    a=c; 

    tf1.setText(""+a); 

    tf2.setText(""+b); 

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

    tf1.setText(""); 

    tf2.setText(""); 

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

    System.exit(0); 

    Screen Shots:

  • 8/20/2019 Assingment File

    19/39

      18

    10) 

    Dummy School uses an interface built in java to check the eligibility of a

    student for a particular stream from sciences, commerce and humanities.

    The user first enters the total percentage and selects the desired stream

    by selecting appropriate option button. An additional 5% marks are given

    to students of NCC. Write code.

    Coding:private void b1ActionPerformed(java.awt.event.ActionEvent evt) { 

    float per; 

    per= Float.parseFloat(tf2.getText()); 

    if (cb.isSelected()==false) 

    tf3.setText(""+per); 

    else 

    tf3.setText(""+(per+5)); 

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

    b1.doClick(); 

    float per = Float.parseFloat(tf3.getText()); 

    if (rb1.isSelected()==true){ 

    if (per>=70) 

    tf4.setText("Eligible!"); 

    else 

    tf4.setText("Not Eligible");} 

    else if (rb2.isSelected()==true){ 

    if (per>=60) 

    tf4.setText("Eligible!"); 

    else 

    tf4.setText("Not Eligible");} 

    else if (rb3.isSelected()==true){ 

    if (per>=40) 

    tf4.setText("Eligible!"); 

  • 8/20/2019 Assingment File

    20/39

      19

    else 

    tf4.setText("Not Eligible");} 

    else 

    JOptionPane.showMessageDialog(null, "Please Select A Subject."); 

    private void

     b3ActionPerformed(java.awt.event.ActionEvent

     evt)

     { 

    group.clearSelection(); 

    cb.setSelected(false); 

    tf1.setText(""); 

    tf2.setText(""); 

    tf3.setText(""); 

    tf4.setText(""); 

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

    System.exit(0); 

    Screen Shots:

  • 8/20/2019 Assingment File

    21/39

      20

    11) 

    Design an application that has some controls and a list displaying colors.

    When a user selects a color from the list the background of the controls

    selected should be changed.

    Coding:

    private void list1ValueChanged(javax.swing.event.ListSelectionEvent evt) { 

    int i; 

    Color x=Color.white; 

    i=list1.getSelectedIndex(); 

    switch (i){ 

    case 0: x=Color.RED; 

    break; 

    case 1: x=Color.BLUE; 

    break; 

    case 2: x=Color.GREEN; 

    break; 

    case 3: x=Color.MAGENTA; 

    break; 

    case 4: x=Color.CYAN;

     

    break; 

    case 5: x=Color.YELLOW; 

    break; 

    case 6: x=Color.GRAY; 

    break; 

    default: x=Color.WHITE; 

    if(lblcb.isSelected()==true) 

    lbl.setBackground(x); 

    else 

  • 8/20/2019 Assingment File

    22/39

      21

    lbl.setBackground(Color.WHITE); 

    if(bcb.isSelected()==true) 

    b.setBackground(x); 

    else 

    b.setBackground(Color.WHITE); 

    if(tfcb.isSelected()==true) 

    tf.setBackground(x); 

    else 

    tf.setBackground(Color.WHITE); 

    Screen Shots:

  • 8/20/2019 Assingment File

    23/39

      22

    12) 

    Design an application which shows all the odd numbers from 1 to the

    number given as input.

    Coding:

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

    ta.setText(null); 

    int n = Integer.parseInt(tf1.getText()); 

    int i = 1; 

    for (; i

  • 8/20/2019 Assingment File

    24/39

      23

    MySQL queries

    Table Student

    1. 

    Displaying whole table

    2. 

    Displaying name and sex of student who are more than 12 years and

    are male.

    3. 

    Displaying name, marks and percentage of all students

  • 8/20/2019 Assingment File

    25/39

      24

    4. 

    Displaying the count of the students who scored more than 50%

    5. 

    Displaying names, marks and sex of students in the order where thetop scorer is first.

    6. 

    Displaying all the information of students where the second alphabet

    of the their name is a.

    7. 

    Displaying the average age of the students

  • 8/20/2019 Assingment File

    26/39

      25

    Table Pet 

    8. 

    Displaying all information about pets whose species is either bird /

    snake / hamster

    9. 

    Displaying all information about pets whose owner’s name contains

    alphabet ‘e’

    10. 

    Displaying No of different species

    11. 

    Displaying name and sex of all the animals born before or on 01-

    01-1995

  • 8/20/2019 Assingment File

    27/39

      26

    Table Empl

    12. 

    Displaying names and job of employees who earn more

    commission than salaries

    13. 

    Displaying all information about employees having 4 lettered

    names

    14. 

    Displaying names, job and salary of employees who don’t have a

    manager

    15. 

    Displaying all information about employees who don’t earn any

    commission

  • 8/20/2019 Assingment File

    28/39

      27

    16. 

    To update salary of salesman by 25%

    17. 

    Displaying the maximum salary

    18. 

    Displaying number of employees in each grade

    Table Dept

    19. 

    Add a column country which cannot be null and by default its

    value should be India

    20. 

    Delete column country

  • 8/20/2019 Assingment File

    29/39

      28

    Table Empl and Dept

    21. 

     Joining both the tables and order them in the order of increasing

    salary

    22. 

    Show all information about employees whose salary is >2000

    23. 

    Drop Database if exists

    24. 

    Displaying current database

  • 8/20/2019 Assingment File

    30/39

      29

    Java MySQL connectivity

    pplications

    1) To create a simple GUI application that displays the records of a database

    table in a tabular format (using jTable) on the GUI form.Coding:

    import java.sql.*; 

    import javax.swing.table.DefaultTableModel; 

    import javax.swing.JOptionPane; 

    Connection c; 

    Statement s; 

    ResultSet rs;

     

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

    DefaultTableModel model= (DefaultTableModel) empl.getModel(); 

    try{ 

    Class.forName("java.sql.Driver"); 

    c=DriverManager.getConnection("jdbc:mysql://localhost/con","root",""); 

    s=c.createStatement(); 

    rs=s.executeQuery("Select * from

     empl;");

     

    while(rs.next()){ 

    int eno=rs.getInt("empno"); 

    String ena=rs.getString("ename"); 

    String j=rs.getString("job"); 

    int mgr=rs.getInt("mgr"); 

    String hd=rs.getString("hiredate"); 

    float sal=rs.getFloat("sal");

     

    float com=rs.getFloat("comm"); 

    int deptno=rs.getInt("deptno"); 

    model.addRow(new Object[] {eno,ena,j,mgr,hd,sal,com,deptno}); 

    rs.close(); 

  • 8/20/2019 Assingment File

    31/39

      30

    s.close(); 

    c.close(); 

    catch (Exception s){ 

    JOptionPane.showMessageDialog(null,"Error In Connectivity"); 

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

    DefaultTableModel model=(DefaultTableModel) empl.getModel(); 

    int row=model.getRowCount(); 

    if(row>0){ 

    for(int i=0;i

  • 8/20/2019 Assingment File

    32/39

      31

    Screen Shots:

  • 8/20/2019 Assingment File

    33/39

      32

    2) To create a simple GUI application that displays the records of a databasetable in a tabular format (using jTable) on the GUI form based on a criteria inputby the user. Coding:

    import java.sql.*; 

    import javax.swing.table.DefaultTableModel; 

    import javax.swing.JOptionPane; 

    Connection c; Statement s; ResultSet r; 

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

    DefaultTableModel model = (DefaultTableModel) empl.getModel(); 

    int rows = model.getRowCount(); 

    if(rows>0){ 

    for (int

     i=0;i

  • 8/20/2019 Assingment File

    34/39

      33

    while(r.next()){ 

    int l = r.getInt("empno"); 

    String m = r.getString("ename"); 

    String n = r.getString("job"); 

    String o = r.getString("hiredate"); 

    float p = r.getFloat("sal");

     

    int q = r.getInt("deptno"); 

    tbprp.addRow(new Object[] {l,m,n,o,p,q}); 

    r.close(); 

    s.close(); 

    c.close(); 

    catch (Exception f){ 

    JOptionPane.showMessageDialog(null,"Error in Connectivity!!"); 

    private void

     b3ActionPerformed(java.awt.event.ActionEvent

     evt)

     { 

    b1.doClick(0); 

    System.exit(0); 

  • 8/20/2019 Assingment File

    35/39

      34

    Screen Shots:

  • 8/20/2019 Assingment File

    36/39

      35

    tm l pages

    1 Logical and Physical Text Styles

    Source

     

    Chapter 10 Example 10.16 (Page No 289) 

     

    Logical And Physical Text Styles
     

    Logical Styles

     

  • 8/20/2019 Assingment File

    37/39

      36

    DFN tag  ‐ HTML is a fomatting language for web pages.
     

    CITE tag  ‐ Newsweek
     

    CODE tag  ‐ printf ("The value of n is%d/n",n)
     

    SAMP tag  ‐ (Abort, Retry , Fail)?
     

    VAR tag  ‐ username
     

    EM tag

      ‐Especially

     the

     Redhead.

     

    KBD tag  ‐  Username, host
     

    STRONG tag  ‐ You cannot be serious!!
     

    Physical Tags

     

    Boldface (done with 'b' tag) looks like this on your machine. 

    Italics (done with 'i' tag) appears like this.
     

    Typewriter (done with 'tt' tag) text uses a fixed‐width font.
     

    Combination of 'i' & 'b' tags. 

     

     

  • 8/20/2019 Assingment File

    38/39

      37

    2 Hyperlinks

  • 8/20/2019 Assingment File

    39/39