MCSL-054 Solved Assignment 2013-14

download MCSL-054 Solved Assignment 2013-14

of 28

description

assignment

Transcript of MCSL-054 Solved Assignment 2013-14

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    PART-I: Lab for MCS-051 (Advanced Internet Technologies)

    Question 1: Write a program using Servlet/JSP that accepts the account number of a

    bank customer as input. The program should print the details of the account. Make

    necessary assumptions whereever required.

    Answer.1

    1){

    ofset = offset*per_page-per_page;

    }

    if((request.getParameter("account_no")!=null) &&

    request.getParameter("account_no")!="")

    {

    String user = session.getAttribute("userid").toString();

    String account_no = request.getParameter("account_no");

    String sd[] = request.getParameter("sdate").toString().split("-");

    String ed[] = request.getParameter("edate").toString().split("-");

    String sdate = sd[2]+"-"+sd[0]+"-"+sd[1] ;

    String edate = ed[2]+"-"+ed[0]+"-"+ed[1];

    Connection conn = null;

    String url = "jdbc:mysql://localhost:3306/";

    String dbName = "userdetails";

    String driver = "com.mysql.jdbc.Driver";

    String username = "root";

    String userPassword = "root";

    String color = "#F9EBB3";

    try {

    Class.forName(driver).newInstance();

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    conn = DriverManager.getConnection(url+dbName,username,userPassword);

    Statement stcount = conn.createStatement();

    String strQuerycount = "select count(*),account_no from transaction where

    username='"+user+"' and account_no='"+account_no+"' and cdate>='"+sdate+"' and

    cdate='"+sdate+"' and cdate

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    Username:

    Name:

    Transaction

    Report

    SNo

    Amount

    Net Amount

    Cash Type

    Date

    conn.close();

    }

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    Question 2: Write a JSP Program, which displays a web page containing two web links one

    for showing schedule of counselling sessions at a Study Centre and other for FAQs on

    Programme on offer by the University. When one click on link Study Centre it goes to a

    page which show the counselling schedule for MCA students. Clicking on link for FAQs

    on Programme on Offer, another JSP page open, which consists of some FAQ related to

    different programme offered in the University.

    Answer.2

    Main.jsp

    Main

    View Details of study

    center

    View Faq on Programs on

    offer

    detailofstudycenter.jsp

    Student Centre Detail Page:

    Study Centre Name :

    Karrox IGNOU Study Centre

    Address :

    karrox technologies Ltd, Opp Shreyas Cinema, Ghatkopar(w),Mumbai-

    86

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    Phone Number :

    022-25699002

    Email :

    [email protected]

    Program Coordinator :

    Mudadi Sanyasi J

    counselling schedule for MCA :

    click here

    faqonprograms.jsp

    FAQs

    FAQs on Practicls

    Q1.

    If attendance is less than 75% in practical session of a course due to some reasons can

    student get any help/consideration?

    Ans : The student will NOT be allowed to appear in Term-End Practical Exam.

    Q2.

    If Attendance is less than 75% then how can a student give Term-End Practical Exam?

    Ans : The student will NOT be allowed to appear in Term-End Practical Exam.

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    Q3.

    Can the MCA students appear in the Term-End Practical Exam without filling the Term-

    End Exam Form ?

    Ans : No.

    Q4.

    What should we do to give my Backlog Term End Practical Exam ?

    Ans : Collect attendance proof from the study Centre & then submit to IGNOU Regional

    Centre before your Term End Examination (Theory).

    Question 3: Write a program using JSP and JDBC to provide details of MCA/BCA/CIT

    students at a IGNOU study centres. Also the program should enable any student to change

    his/her address. This program should provide the practical attendance detail of students in

    different semesters of MCA/BCA/CIT.

    Answer.3

    index.jsp

    Select your regional center

    Please select one

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    while(res.next()) {

    %>

    page2.jsp

    JSP Page

    Back

    Student details for different

    semester(MCA,BCA and CIT) regional center wise

    Study center details

    Id

    Name

    Address

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    ResultSet res = stmt.executeQuery("select sid,sname,address from

    studycenter where rid="+rid+"");

    while(res.next()) {

    %>

    page3.jsp

    JSP Page

    Back

    Student details

    Id

    Name

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    Gender

    Age

    Address

    Course

    Semester

    page4.jsp

    JSP Page

    Back

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    Student details

    Id

    Name

    Gender

    Age

    Address

    Course

    Semester

    DBConnection.java

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    package database;

    import java.sql.*;

    public class DBConnection {

    /** Creates a new instance of DBConnection */

    public DBConnection() { }

    /*

    *

    */

    public static Connection getDBConnection()

    {

    Connection con = null;

    try

    {

    Class.forName("com.mysql.jdbc.Driver");

    }

    catch(ClassNotFoundException e)

    {

    System.out.println("Could not load driver class "+e);

    }

    try

    {

    con =

    DriverManager.getConnection("jdbc:mysql://localhost:3306/ignou","root","root");

    }

    catch (SQLException e) {System.out.println("Could not get connection "+e);}

    return con;

    }

    public static void closeDBConnection(Connection con)

    {

    try

    {

    if(con!=null) con.close();

    }

    catch (SQLException e) {

    System.out.println("Could not close connection "+e);

    }

    }

    public static void main(String[] args) {

    getDBConnection();

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    }

    }

    ignou.sql

    CREATE DATABASE IF NOT EXISTS ignou;

    USE ignou;

    DROP TABLE IF EXISTS `ignou`.`courses`;

    CREATE TABLE `ignou`.`courses` (

    `cid` int(11) NOT NULL AUTO_INCREMENT,

    `cname` varchar(100) DEFAULT NULL,

    PRIMARY KEY (`cid`)

    ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

    LOCK TABLES `courses` WRITE;

    INSERT INTO `ignou`.`courses` VALUES (2,'BCA'),

    (3,'CIT'),

    (1,'MCA');

    UNLOCK TABLES;

    DROP TABLE IF EXISTS `ignou`.`regionalcenter`;

    CREATE TABLE `ignou`.`regionalcenter` (

    `rid` int(11) NOT NULL AUTO_INCREMENT,

    `rname` varchar(100) DEFAULT NULL,

    `address` text,

    PRIMARY KEY (`rid`)

    ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

    LOCK TABLES `regionalcenter` WRITE;

    INSERT INTO `ignou`.`regionalcenter` VALUES (1,'Jaipur','Mansarovar Jaipur'),

    (2,'Mumbai','Mulund Mumbai');

    UNLOCK TABLES;

    DROP TABLE IF EXISTS `ignou`.`student`;

    CREATE TABLE `ignou`.`student` (

    `name` varchar(100) DEFAULT NULL,

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    `gender` varchar(6) DEFAULT NULL,

    `age` int(11) DEFAULT NULL,

    `address` text,

    `cid` int(11) DEFAULT NULL,

    `sid` int(11) DEFAULT NULL,

    `id` int(11) NOT NULL AUTO_INCREMENT,

    `sem` int(11) DEFAULT NULL,

    `rid` int(11) DEFAULT NULL,

    PRIMARY KEY (`id`)

    ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

    LOCK TABLES `student` WRITE;

    INSERT INTO `ignou`.`student` VALUES ('Meena','Female',25,'Mumbai

    (MH)',2,2,2,4,2),

    ('Deepak','Male',25,'Alsisar, Jhunjhunu (Rajasthan)',1,1,1,5,1);

    UNLOCK TABLES;

    DROP TABLE IF EXISTS `ignou`.`studycenter`;

    CREATE TABLE `ignou`.`studycenter` (

    `address` text,

    `sid` int(11) NOT NULL,

    `sname` varchar(100) DEFAULT NULL,

    `rid` int(11) DEFAULT NULL,

    PRIMARY KEY (`sid`)

    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    LOCK TABLES `studycenter` WRITE;

    INSERT INTO `ignou`.`studycenter` VALUES ('Jaipur',1,'IIIM',1),

    ('Mumbai',2,'ABCD',2);

    UNLOCK TABLES;

    Question 4: Create an XML document for keeping students record in a department of a

    University.

    Answer.4

    Ajay Mishra

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    MCA

    063501077

    H-45 Indira Nagar

    9444444685

    Shweta Sankhla

    MCA

    063502656

    A-17 Sangam Nagar Indore

    9958888889

    Issued.jsp

    Search.jsp

    Enter Book name Search For availability

    PART-II: Lab for MCS-053 (Computer Graphics and Multimedia)

    Question 1: Write a program in C/C++ using OpenGL to draw a rectangle of red colour

    inside of a circle of blue colour on a background of orange colour.

    Answer.

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    #include

    #include

    #include

    const float PI=3.14;

    void drawCircle(){

    glBegin(GL_LINE_LOOP);

    glColor3f(1.0,0.0,0.0);

    for(int i =0; i

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    return 0;

    }

    Question 2: Write a program in C or C++ to implement Scan-Line Polygon Filling

    Algorithm.

    Answer.

    typedef struct tEdge

    {

    int yUpper;

    float xIntersect, dxPerScan;

    struct tEdge * next;

    } Edge;

    typedef struct tdcPt

    {

    int x;

    int y;

    } dcPt;

    void scanFill (int cnt, dcPt * pts)

    {

    Edge * edges[WINDOW_HEIGHT], * active;

    int i, scan;

    for (i=0; inext = NULL;

    }

    buildEdgeList (cnt, pts, edges);

    active = (Edge *) malloc (sizeof (Edge));

    active->next = NULL;

    for (scan=0; scannext)

    {

    fillScan (scan, active);

    updateActiveList (scan, active);

    resortActiveList (active);

    }

    }

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    /* Free edge records that have been malloced ... */ }

    void scanFill (int cnt, dcPt * pts)

    {

    Edge * edges[WINDOW_HEIGHT], * active;

    int i, scan;

    for (i=0; inext = NULL;

    }

    buildEdgeList (cnt, pts, edges);

    active = (Edge *) malloc (sizeof (Edge));

    active->next = NULL;

    for (scan=0; scannext)

    {

    fillScan (scan, active);

    updateActiveList (scan, active);

    resortActiveList (active);

    }

    }

    /* Free edge records that have been malloced ... */ }

    void buildEdgeList (int cnt, dcPt * pts, Edge * edges[])

    {

    Edge * edge;

    dcPt v1, v2;

    int i, yPrev = pts[cnt - 2].y;

    v1.x = pts[cnt-1].x; v1.y = pts[cnt-1].y;

    for (i=0; i

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    v1 = v2;

    }

    }

    /* For an index, return y-coordinate of next nonhorizontal line */

    int yNext (int k, int cnt, dcPt * pts)

    {

    int j;

    if ((k+1) > (cnt-1))

    j = 0;

    else

    j = k + 1;

    while (pts[k].y == pts[j].y)

    if ((j+1) > (cnt-1))

    j = 0;

    else

    j++;

    return (pts[j].y);

    }

    void buildEdgeList (int cnt, dcPt * pts, Edge * edges[])

    {

    Edge * edge;

    dcPt v1, v2;

    int i, yPrev = pts[cnt - 2].y;

    v1.x = pts[cnt-1].x; v1.y = pts[cnt-1].y;

    for (i=0; idxPerScan =(float) (upper.x - lower.x) / (upper.y - lower.y);

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    edge->xIntersect = lower.x;

    if (upper.y < yComp)

    edge->yUpper = upper.y - 1;

    else

    edge->yUpper = upper.y;

    insertEdge (edges[lower.y], edge);

    }

    /* Inserts edge into list in order of increasing xIntersect field. */

    void insertEdge (Edge * list, Edge * edge)

    {

    Edge * p, * q = list;

    p = q->next;

    while (p != NULL)

    {

    if (edge->xIntersect < p->xIntersect)

    p = NULL;

    else

    {

    q = p;

    p = p->next;

    }

    }

    edge->next = q->next;

    q->next = edge;

    }

    void scanFill (int cnt, dcPt * pts)

    {

    Edge * edges[WINDOW_HEIGHT], * active;

    int i, scan;

    for (i=0; inext = NULL;

    }

    buildEdgeList (cnt, pts, edges);

    active = (Edge *) malloc (sizeof (Edge));

    active->next = NULL;

    for (scan=0; scannext)

    {

    fillScan (scan, active);

    updateActiveList (scan, active);

    resortActiveList (active);

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    }

    }

    /* Free edge records that have been malloced ... */ void buildActiveList (int scan, Edge * active, Edge * edges[])

    {

    Edge * p, * q;

    p = edges[scan]->next;

    while (p)

    {

    q = p->next;

    insertEdge (active, p);

    p = q;

    }

    }

    void scanFill (int cnt, dcPt * pts)

    {

    Edge * edges[WINDOW_HEIGHT], * active;

    int i, scan;

    for (i=0; inext = NULL;

    }

    buildEdgeList (cnt, pts, edges);

    active = (Edge *) malloc (sizeof (Edge));

    active->next = NULL;

    for (scan=0; scannext)

    {

    fillScan (scan, active);

    updateActiveList (scan, active);

    resortActiveList (active);

    }

    }

    /* Free edge records that have been malloced ... */ }

    void fillScan (int scan, Edge * active)

    {

    Edge * p1, * p2;

    int i;

    p1 = active->next;

    while (p1)

    {

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    p2 = p1->next;

    for (i=p1->xIntersect; ixIntersect; i++)

    setPixel ((int) i, scan);

    p1 = p2->next;

    }

    }

    void scanFill (int cnt, dcPt * pts)

    {

    Edge * edges[WINDOW_HEIGHT], * active;

    int i, scan;

    for (i=0; inext = NULL;

    }

    buildEdgeList (cnt, pts, edges);

    active = (Edge *) malloc (sizeof (Edge));

    active->next = NULL;

    for (scan=0; scannext)

    {

    fillScan (scan, active);

    updateActiveList (scan, active);

    resortActiveList (active);

    }

    }

    /* Free edge records that have been malloced ... */ }

    /* Delete completed edges. Update xIntersect field for others */ void updateActiveList (int scan, Edge * active)

    {

    Edge * q = active, * p = active->next;

    while (p)

    if (scan >= p->yUpper)

    {

    p = p->next;

    deleteAfter (q);

    }

    else

    {

    p->xIntersect = p->xIntersect + p->dxPerScan;

    q = p;

    p = p->next;

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    }

    }

    void deleteAfter (Edge * q)

    {

    Edge * p = q->next;

    q->next = p->next;

    free (p);

    }

    void scanFill (int cnt, dcPt * pts)

    {

    Edge * edges[WINDOW_HEIGHT], * active;

    int i, scan;

    for (i=0; inext = NULL;

    }

    buildEdgeList (cnt, pts, edges);

    active = (Edge *) malloc (sizeof (Edge));

    active->next = NULL;

    for (scan=0; scannext)

    {

    fillScan (scan, active);

    updateActiveList (scan, active);

    resortActiveList (active);

    }

    }

    /* Free edge records that have been malloced ... */ }

    void resortActiveList (Edge * active)

    {

    Edge * q, * p = active->next;

    active->next = NULL;

    while (p)

    {

    q = p->next;

    insertEdge (active, p);

    p = q;

    }

    }

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    Question 3: Write a program in C or C++ to implement Cyrus Beck line clipping algorithm.

    Answer. // Cyrus-Beck Line Clipping algorithm

    struct Point2D

    { float x,y;

    }

    const int MAXP = 100;

    struct Polygon

    { int nPoints;

    Point2D v[MAXP];

    }

    const int MAXN = 100;

    typedef Point2D Normal[MAXN];

    void CalcNormals (Polygon p, Normal & n)

    { int i,j,k;

    point2D v;

    for (i = 0; i < p.nPoints; i++)

    { j = (i+1)%p.nPoints;

    k = (i+2)%p.nPoints;

    // make vector be -1/mI + 1J

    n[i].x = -(p.v[j].y - p.v[i].y)/(p.v[j].x - p.v[i].x);

    n[i].y = 1.0;

    v.x = p.v[k].x - p.v[i].x;

    v.y = p.v[k].y - p.v[i].y;

    if (DotProduct (n[i],v) > 0) // inner normal

    { n[i].x *= -1;

    n[i].y = -1;

    }

    }

    }

    float DotProduct (Point2D v1, Point2D v2)

    {

    return v1.x*v2.x + v1.y*v2*y;

    }

    void CBClip (Point2D p1, Point2D p2, Normal n, Polygon p, Boolean &

    visible,

    Point2D & rp, Point2D & q)

    { float t1,t2,t,num,den;

    Point2D dirV,F; // vectors

    int I;

    t1 = 0.0;

    t2 = 1.0;

    // compute the direction vector

    dirV.x = p2.x - p1.x;

    dirV.y = p2.y - p1.y;

    visible = TRUE;

    i = 0;

    while ( (i < p.nPoints) && visible)

    { F.x = p1.x - p.v[i].x;

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    F.y = p1.y - p.v[i].y;

    num = DotProduct (n[i],F);

    den = DotProduct (n[i],dirV);

    if (den == 0.0) // Parallel or Point

    { if (num > 0.0)

    visible = FALSE; // Parallel and outside or point (p1 ==

    p2) and outside

    }

    else

    { t = -(num/den);

    if (den < 0.0) // entering

    { if (t t1)

    t1 = t;

    }

    else if ( t >= 0.0) //exiting

    if (t < t2)

    t2 = t;

    }

    i++;

    }

    if ( t1

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    glvertex 3f (1. 0 f, - 0.0f, 0.0f);

    glvertex 2f (-1. 8 f, - 0.1f );

    glvertex 2f (-1. 2 f, - 0.1f );

    glvertex 2f (-1. 2 f, - 0.7f );

    glvertex 2f (-1. 8 f, - 0.7f );

    glvertex 2f (-3.0 f, s.of, 2.9f );

    glEnd ( );

    }

    Question 5: Write a program in C/C++ using OpenGL to implement Sutherland Hodgman

    polygon clipping algorithm to clip the following polygon against the rectangular window as

    given below. Make suitable assumptions.

    Answer.

    #include

    #include

    struct Point{

    float x,y;

    } w[4],oVer[4];

    int Nout;

    void drawPoly(Point p[],int n){

    glBegin(GL_POLYGON);

    for(int i=0;i=w[0].x)&&(p.x=w[0].y)&&(p.y

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    Point in;

    float m;

    if(w[edge].x==w[(edge+1)%4].x){ //Vertical Line

    m=(p.y-s.y)/(p.x-s.x);

    in.x=w[edge].x;

    in.y=in.x*m+s.y;

    }

    else{//Horizontal Line

    m=(p.y-s.y)/(p.x-s.x);

    in.y=w[edge].y;

    in.x=(in.y-s.y)/m;

    }

    return in;

    }

    void clipAndDraw(Point inVer[],int Nin){

    Point s,p,interSec;

    for(int i=0;i

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    drawPoly(oVer,4);

    }

    void init(){

    glClearColor(0.0f,0.0f,0.0f,0.0f);

    glMatrixMode(GL_PROJECTION);

    glLoadIdentity();

    glOrtho(0.0,100.0,0.0,100.0,0.0,100.0);

    glClear(GL_COLOR_BUFFER_BIT);

    w[0].x =20,w[0].y=10;

    w[1].x =20,w[1].y=80;

    w[2].x =80,w[2].y=80;

    w[3].x =80,w[3].y=10;

    }

    void display(void){

    Point inVer[4];

    init();

    // As Window for Clipping

    glColor3f(1.0f,0.0f,0.0f);

    drawPoly(w,4);

    // As Rect

    glColor3f(0.0f,1.0f,0.0f);

    inVer[0].x =10,inVer[0].y=40;

    inVer[1].x =10,inVer[1].y=60;

    inVer[2].x =60,inVer[2].y=60;

    inVer[3].x =60,inVer[3].y=40;

    drawPoly(inVer,4);

    // As Rect

    glColor3f(0.0f,0.0f,1.0f);

    clipAndDraw(inVer,4);

    // Print

    glFlush();

    }

    int main(int argc,char *argv[]){

    glutInit(&argc,argv);

    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);

    glutInitWindowSize(400,400);

    glutInitWindowPosition(100,100);

    glutCreateWindow("Polygon Clipping!");

    glutDisplayFunc(display);

    glutMainLoop();

    return 0;

  • MCSL-054 Solved assignment 2013-14

    By Sheel:- [email protected]

    Write at your own risk

    For More Ignou Solved Assignments Please Visit - www.ignousolvedassignments.com

    Connect on Facebook :

    http://www.facebook.com/pages/IgnouSolvedAssignmentscom/346544145433550

    Subscribe and Get Solved Assignments Direct to your Inbox :

    http://feedburner.google.com/fb/a/mailverify?uri=ignousolvedassignments_com