Likes

BookHive Corp. Project Sem 4

BookHive Corp. 
Project Sem 4

Bookhive Corp. is a leading publishing house in the US. The company headquarter is located in Atlanta. It has been publishing books, articles, journals, novels, magazines, and encyclopedias for the past fifteen years. The customers of the company include students, IT professionals, and research scholars. The company enjoys a dominant position in the publishing business with 15 retail stores in all major cities in the US.
The Current System
At present, Bookhive sells books only through its retail stores, which limits the company's consumer base. Each store has a Store Manager, who is responsible for managing the operations of a store.
Presently, the company depends on the print and electronic media to advertise its books. There is a static website that is periodically updated whenever a new book is released. Many competitors of the company already have their e-commerce stores and are selling books online. Bookhive is losing its customers to competitors because people prefer buying books online, without having to visit a retail store. Customers often complain that due to an inadequate number of stores in their city, they have to travel a long distance to reach a store. In addition, customers visiting a store complain that, at times, the books that they are looking for are not available in the stores.
Hence, many orders remain unplaced and customers are dissatisfied. As a result, there has been a loss in the company's revenue.
The Envisioned System
It is evident that the existing business model is insufficient to meet customer demands.
To address the current limitations, the management has tied up with a software development organization. The management has instructed the organization to create an online book store application that can be globally used to order books. In the first phase, the Bookhive application will simplify the process of managing stocks and enable the organization to sell books online. The application should provide a consistent mechanism to enable customers to buy books online and administrators to manage book stocks online. Currently, the management wants that all orders should be processed at a centralized location and delivered through the relevant store. Later, each store will have its own interface through which it will be able to manage the orders pertaining to that store.
To provide the envisioned functionalities, the Bookhive application should have the following features during the first phase of its development:
  • The application should be accessible over the Internet.
  • The application should be accessible to the customer and the administrator. The customer role should be applicable to any user accessing the application to order books online.
  • The system should allow a customer to perform the following activities:
    • Browse through book categories.
    • View details of a book.
    • Add and remove books from a shopping basket while browsing the categories.
    • Place an order of books by providing delivery information.
  • The system should have an authentication mechanism to verify the credentials of a Bookhive employee assigned with the administrator role.
  • The system should have an authorization mechanism to restrict access to administrative functions based on the fact whether the current user is an administrator or not.
  • The system should allow an administrator to perform the following activities:
    • View details of books.
    • Add new books to the book catalogue.
    • Delete books from the book catalogue.
    • Update book information, such as book category, availability, and price.
    • View status of orders placed by customers.
    • Update the status of an order once the order is delivered.
  • The system should have a mechanism, where a store can provide festive discounts on specific books by providing the discount information in an XML file.
To fulfill the preceding requirements, the following specifications have been laid down to design the Bookhive application:
  • Application should be developed in ASP.NET MVC.
  • Design, layout, and navigation of the application should be uniform across all Web pages.
  • Book ordering activities should be tracked across a user's session through a shopping cart.
  • Order details of a customer should be persisted in a database.
  • User authentication should be form-based.
  • User authorization should be role-based.
  • Data provided by the user must be validated.
  • Festive discounts on online orders should be easily configured through an XML file.
  • Static views of the application should be cached.
  • Application should provide information on the company's profile and its contact details.





As an ASP.NET developer, you have been assigned the task to create the Bookhive application.

Download link 



BSC-IT 5TH SEMESTER PRACTICAL SOLUTIONS




Set 1

//1. Open an Image. And separate background using selection tool.
Step 1: run Photoshop
Step 2: go to file menu -> open
Step 3: select image ->click open
Step 4: click on magic wand tool from tool menu
Step 5: select on background of the image using magic wand tool
Step 6: press delete on keyboard
Step 7: go to file menu -> save as
Step 8: select JPEG format
Step 9: enter file name -> click SAVE//2. Write a JSP page to display the number of hits to this page. (Hint: use application scope of java bean).
<%@ page session=”false” %>
<HTML>
<HEAD>
<TITLE>Page Counter Using URL Rewriting</TITLE>
</HEAD>
<BODY>
<H3>Page Counter Using URL Rewriting</H3>
<%
int count = 0;
String parm = request.getParameter(“count”);
if (parm != null)
count = Integer.parseInt(parm);
if (count == 0) {
%> This is the first time you have accessed this page. <%
}
else if (count == 1) {
%> You have accessed the page once before.<%
}
else {
%> You have accessed the page <%= count %> times before.<%
}
%>
<P> Click
<A HREF=”urlrewriting.jsp?count=<%=count + 1 %>”
>here</A> to visit the page again.
</BODY>
</HTML>

Set 2//1. Using pencil tool create an image of landscape, and color it with Brush tool.
Step 1: run Photoshop
Step 2: click file menu -> new -> select size -> press OK
Step 3: in dialog box, click on preset -> select landscape in size box -> press OK
Step 4: click on pencil tool in tool menu
Step 5: draw an image in landscape using pencil tool
Step 6: right click on pencil tool and select brush tool
Step 7: using brush tool, fill the color in landscape image
Step 8: go to file menu -> save as
Step 9: select JPEG format
Step 10: enter file name -> click SAVE//2. Create an HTML page containing the following features
a. Create a login JSP page with username, password and submit button. 
b. On submit, display message ‘Thank you for logging in’ also create cookies to store username and password.
c. Open login JSP page on a new browser. If the cookie is present the username and password field should be automatically populated with the values from the cookie.
<%@page contentType=”text/html”%>
<html>
<head>
<title></title>
</head>
<body>
<center>
<form action=”next.jsp” method=”post”>
Please Enter Your Detials !<br>
First Name    <input type=”text” name=”firstname”><br>
Last Name     <input type=”text” name=”lastname”><br>
<input type=”submit” name=”submit” value=”Submit”>
</form>
</center>
</body>
</html>Next.jsp
<%@page contentType=”text/html”%>
<%@page pageEncoding=”UTF-8?%>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8?>
<title>JSP Page</title>
</head>
<body>
<%
String firstname=request.getParameter(“firstname”);
String lastname=request.getParameter(“lastname”);out.println(“<font color=blue>Welcome</font>    ”+firstname+” “+lastname+”  Thank you for loging in!”);
%>
</body>
</html>Set 3//1. Write a JSP program to display current date and time and suitable welcome message. 
a. If time is between 5AM and 12 PM display welcome message as ‘Good Morning’
b. If time is between 12 PM and 5 PM display welcome message as ‘Good Afternoon’
c. After 5PM display message as ‘Good evening’.
<%@page language=”java”%>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h1>
<% java.util.Date d=new java.util.Date();
int time=d.getHours();
if(time>5 && time<12)
out.println(“\n Good Morning !”);
esle if(time>12 && time<17)
out.println(“\n Good Afternoon !”);
else if(time>17)
out.println(“\n Good Evening !”);
%>
</h1>
current time is :<%=d.getHours()%>:<%=d.getMinutes()%>
</body>
</html>

//2. Using Rubberstamp tool, create a clone image
Step 1: run Photoshop
Step 2: go to file menu -> open
Step 3: select image -> click open
Step 4: select rubberstamp tool from tool menu
Step 5: press ALT then left click on image to begin
Step 6: click on the image and drag where you want to make clone of that image
Step 7: go to file -> save as
Step 8: select JPEG format
Step 9: enter file name -> click SAVE
Set 4
//1. Using Gradient tool, create some backgrounds for photos.
Step 1: run Photoshop
Step 2: go to file menu -> new -> select size -> press ok
Step 3: select gradient tool from tool menu
Step 4: choose gradient (linear/ radial/ angle/ diamond) from option toolbar
Step 5: press left click on mouse then drag on image to create gradient
Step 6: go to file -> save as
Step 7: select JPEG format
Step 8: enter file name -> click SAVE
//2. .Create an HTML page containing the following features
a. A combo box containing the list of 7 colors: Violet, Indigo, Blue, Green, Yellow, Orange, Red
b. Depending upon the color selected from the above combo box, the message in the status bar of the window must be reflect the value selected in the combo box (hint: on change event of the combo box).
<html>
<head>
<title>Showing Message in Status Bar</title>
</head>
<body>
<script language=”JavaScript”>
functionfn()
{
num=document.frm.vibgyor.selectedIndex;
if(num==0)
{
window.status=”You have selected Violet.”;
}
if(num==1)
{
window.status=”You have selected Indigo.”;
}
if(num==2)
{
window.status=”You have selected Blue.”;
}
if(num==3)
{
window.status=”You have selected Green.”;
}
if(num==4)
{
window.status=”You have selected Yellow.”;
}
if(num==5)
{
window.status=”You have selected Orange.”;
}
if(num==6)
{
window.status=”You have selected Red.”;
}
}
</script>
<form name=”frm”>
<select name=”vibgyor” onChange=fn()><option>Violet</option>
<option>Indigo</option>
<option>Blue</option>
<option>Green</option>
<option>Yellow</option>
<option>Orang</option>
<option>Red</option>
</select>
</form>
</body>
</html>
Set 5

//1. Create an HTML page containing the following features
a. A combo box containing the list of  7 colors: Violet, Indigo, Blue, Green, Yellow, Orange, Red
b. An empty 1X1 table with default background color: White
c. Depending upon the color selected from the above combo box, the background of the table must be changed accordingly. (hint: on change event of the combo box). 
<html>
<head>
<title>
Changing Table Color by selecting color from the ComboBox
</title>
</head>
<body>
<script language= “JavaScript”>
functionfn()
{
num=document.frm.vibgyor.selectedIndex;
if(num==0)  {
document.getElementById(“tab”).bgColor=”Violet”;
}
if(num==1)
{
document.getElementById(“tab”).bgColor=”Indigo”;
}
if(num==2)  {
document.getElementById(“tab”).bgColor=”Blue”;
}
if(num==3)
{
document.getElementById(“tab”).bgColor=”Green”;
}
if(num==4)
{
document.getElementById(“tab”).bgColor=”Yellow”;
}
if(num==5)
{
document.getElementById(“tab”).bgColor=”Orange”;
}  if(num==6)
{
document.getElementById(“tab”).bgColor=”Red”;
}
}
</script>
<form name=”frm”>
<select name=”vibgyor” onChange=fn()>
<option>Violet</option>
<option>Indigo</option>
<option>Blue</option>
<option>Green</option>
<option>Yellow</option>
<option>Orange</option>
<option>Red</option>
</select><br><br><br><br>
<table id=”tab” border=”1?>
<tr>
<th>Name</th>
<th>Registration Number</th>
</tr>
<tr>
<td>priyanka rani</td>
<td>072B5725</td>
</tr>
</table>
</form>
</body>
</html>

//2. Import a ‘JPEG’ format image and save it as a ‘PSD’ image, using  layer options
Decrease the opacity of image.
Tips: Ctrl + Shift + S   = ‘save as’ window
Step 1: run Photoshop
Step 2: go to file menu -> open
Step 3: select a JPEG image -> click open
Step 4: go to layer -> new -> click on ‘layer from background’
Step 5: enter layer name in dialog box -> press OK
Step 6: press F7 then decrease opacity
Step 7: go to file -> save as
Step 8: select PSD format
Step 9: enter file name -> click SAVE

Set 6
//1. Open a PORTRAIT image, convert it into grayscale. Now color the image Using COLOR BALANCE, LEVELS and CURVES
Step 1: run Photoshop
Step 2: go to file menu -> open
Step 3: select a portrait JPEG image ->click open
Step 4: go to image -> mode -> click on Grayscale
Step 5: click “discard” in message box
Step 6: go to image -> adjustments -> image -> click on ‘curves’
Step 7: adjust curves -> press OK
Step 8: go to file -> save as
Step 9: select JPEG format
Step 10: enter file name -> click SAVE

//2. Write a HTML page containing an HTML form to capture the following properties from the user:
a. Name (text box)
b. Address (text area)
c. Phone (text box)

Write javascript functions 
a. to validate Name to contain only alphabets and of maximum length should be 25 ; Show appropriate messages on failure 
b. to validate Address field to contain maximum length of 200 characters; Show appropriate on failure and focus the ‘Address’ field text area
c. to validate phone number to contain only numeric data; show appropriate messages on failure
<html>
<head>
<title>
HTML form
</title>
<Script language=”javaScript”>
function f()
{
var name=document.f1.Name.value;
var phone=document.f1.Phone.value;
var address=document.f1.Address.value;
if(name.length==””)
{
alert(“Please enter name”);
name.focus();
return;
}
if (name.length> 25)
{
alert(“Name Field cannot contain more than 25 characters”);
name.focus();
return;
}
if (!isNaN(name))
{
alert(“Name field must be filled with only Alphabets”);
name.focus();
return;
}
if(phone.length==””)
{
alert(“Please enter phone numbar”);
phone.focus();
return;
}
if (isNaN(phone))
{
alert(“Phone Number must be numeric”);
phone.focus();
return;
}
if(address.length==””)
{
alert(“Please enter address”);
address.focus();
return;
}
if (address.length> 200)
{
alert(“Address Field can contain maximum of 200 character”);
}
}
</script>
</head>
<body bgcolor=”pink”>
<marquee><h1 align=”center”>A Sample FORM </h1></marquee>
<form name=f1>
Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=textbox name=”Name”><br>
Phone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=textbox name=”Phone”><br>
Address:&nbsp;&nbsp;<textarea rows=”5? cols=”50? name=”Address”></textarea><BR>
<input type=Button name=”Button” value =”Submit” onclick=f()>
</form>
</body>
</html>

Set 7

//1. Create two HTML pages
a. First page with the following features
i. An image(logo) with a company name as the heading in the top center
ii. This page containing an HTML form, two text boxes to get First Name, Second Name of the user
iii. A submit button to the submit the data to the next page
b. The Second page receives the data submitted by the First Page, displays the following message
Welcome <Last Name>, <First Name>
<html>
<head>
<title></title>
</head>
<body>
<center><img src=”NIITLogo.jpg”></center>
<center>
<form action=”ToShowDataToAnotherPage” method=”post”>
Please Enter Your Detials !<br>
First Name    <input type=”text” name=”firstname”><br>
Last Name     <input type=”text” name=”lastname”><br>
<input type=”submit” name=”submit” value=”Submit”>
</form>
</center>
</body>
</html>
ToShowDataToAnotherPage  servlet
import java.io.*;
import java.net.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
public class ToShowDataToAnotherPage extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throwsServletException, IOException {
response.setContentType(“text/html;charset=UTF-8?);
PrintWriter out = response.getWriter();
String firstname=request.getParameter(“firstname”);
String lastname=request.getParameter(“lastname”);
out.println(“<font color=blue>Welcome</font>    ”+firstname+” “+lastname);
}
}

//2. Open a portrait, select the eyeballs using marquee tool, and now change the color of eyes using Hue / saturation.
Tips: Ctrl + U = Hue / saturation
Step 1: run Photoshop
Step 2: go to file menu -> open
Step 3: select image ->click open
Step 4: click on marquee tool from tool menu
Step 5: select eyeball from the image using marquee tool
Step 6: press CTRL+U
Step 7: adjust HUE AND SATURATION from dialog box -> press OK
Step 8: go to file -> save as
Step 9: select JPEG format
Step 10: enter file name -> click SAVE

Set 8


//1. Open 3 to 4 images in a same layer. Using filter effects create creative backgrounds for book cover page.
Step 1: run Photoshop
Step 2: go to file menu -> new -> select background size -> press OK
Step 3: go to filter -> noise -> add noise
Step 4: adjust amount in noise dialog box -> press OK
Step 5: go to file menu -> open
Step 6: select 3-4 images -> click open
Step 7: select images, copy and paste them in background one by one
Step 8: go to file -> save as
Step 9: select JPEG format
Step 10: enter file name -> click SAVE

//2. Create a HTML page to display a list of film songs available in the library. The following are features of the page
a. The name of the songs must be hyper linked to the songs, so that the users must be able to download songs.
b. The following is the song database available in the library:
c. Library Name: Hariharan Music Site
 Slno Song Name      Film          Artiste
      1 PATA-PATA Apthamitra Udith Narayan
      2 Kana Kanade Apthamitra Madhubalakrishna
      3 Anku Donku Apthamitra S P Balasubramanyam
      4 Kalavanu        Thadeyoru Apthamitra Hariharan
      5 Bombe      Anayya      Unknown
<html>
<head>
<tittle>
Hiriharan Songs Site
</title>
</head>
<body>
<marquee><font color = blue><b>Welcome to Hariharan’s Songs Site</b></font></marquee>
<center>
<table border=1>
<tr>
<th>S.No.</th>
<th>Song Name</th>
<th>Film</th>
<th>Artist</th>
<tr>
<tr>
<td>1.</td>
<td><a href=”song1.html”>Patta-Patta</a></td>
<td>Apthamitra</td>
<td>Udit Narayan</td>
</tr>
<tr>
<td>2.</td>
<td><a href=”song2.html”>Kana Kanede</a></td>
<td>Apthamitra</td>
<td>Madhubalakirishna</td>
</tr>
<tr>
<td>3.</td>
<td><a href=”song3.html”>AnkuDonku</a></td>
<td>Apthamitra</td>
<td>S P Balasupramanniyam</td>
</tr>
<tr>
<td>4.</td>
<td><a href=”song4.html”>Bombay</a></td>
<td>Anaya</td>
<td>Unknown</td>
</tr>
</table>
</center>
</body>
</html>

Set 9

//1. Create an HTML page to display the following data using <table></table> tags

First Name Last Name City Phone Number  
Shiva Rama Mysore 08212569964
Pratap S         Bangalore  08025689754
Sreenivas   G          Mercara         08965445454
<html>
<head>
</head>
<tittle>
Data Table
</title>
<body>
<table border=1>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>City</th>
<th>Phone Number</th>
<tr>
<tr>
<td>Shiva</td>
<td>Rama</td>
<td>Mysore</td>
<td>08212569964</td>
</tr>
<tr>
<td>Pratap</td>
<td>S</td>
<td>Bangalore</td>
<td>08025689754</td>
</tr>
<tr>
<td>Shrinivas</td>
<td>G</td>
<td>Mercara</td>
<td>08965445454</td>
</tr>
</table>
</body>
</html>

//2. Open an image and adjust a level of image. 
Tips: Ctrl + L = level
Step 1: run Photoshop
Step 2: go to file menu -> open
Step 3: select an image -> click open
Step 4: go to image -> adjustments -> click on level or press ctrl + l
Step 5: adjust level -> press OK
Step 6: go to file -> save as
Step 7: select JPEG format
Step 8: enter file name -> click SAVE

Set 10

//1. Write HTML script to display “Hello World, Welcome to the world of HTML”. Put the title as “World of HTML”
<html>
<head>
</head>
<title>
Welcome to the world of HTML
</title>
<body>
<i>”Hello World</i><b>Welcome to the world of HTML”</b>
</body>
</html>

//2. Change an image size 22 cm x 29 cm to 44 cm x 58 cm. and resolution 72 to 300.
Step 1: run Photoshop
Step 2: go to file menu -> open
Step 3: select an image with 22 cm x 29 cm size -> click open
Step 4: go to image -> image size
Step 5: change image size to 44 cm x 58 cm size with 100 resolutions -> press OK
Step 6: go to file -> save as
Step 7: select JPEG format
Step 8: enter file name -> click SAVE

Set 11

//1. Create some geometrical shapes, using shape tool.
Step 1: run Photoshop
Step 2: go to file menu -> new -> select size -> press OK
Step 3: click on ‘custom shape tool’ from tool menu
Step 4: click on ‘custom shape picker’ in options toolbar
Step 5: click on smart tag -> select all then click append
Step 6: choose shape from option toolbar
Step 7: left click on background and drag mouse to draw shape
Step 8: go to file -> save as
Step 9: select JPEG format
Step 10: enter file name -> click Save

Set 12

//1. Type text ‘GRADATION’ and apply gradient tool on text.
Step 1: run Photoshop
Step 2: go to file menu -> new -> select size -> click OK
Step 3: click on text from tool menu
Step 4: type text “GRADATION”
Step 5: click on layer from layer property
Step 6: right click on selected layer and click on ‘blending options’
Step 7: click and check on ‘gradient overlay’
Step 8: adjust gradient or change angle to 0o -> then press OK
Step 9: go to file menu -> save as
Step 10: select JPEG format
Step 11: enter file name -> click SAVE

//2. Create an HTML page to display the following data using <table></table> tags
First Name Last Name City Phone Number  
Shiva Rama Mysore 08212569964
Pratap S         Bangalore 08025689754
Sreenivas    G               Mercara    08965445454
<html>
<head>
</head>
<tittle>
Data Table
</title>
<body>
<table border=1>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>City</th>
<th>Phone Number</th>
<tr>
<tr>
<td>Shiva</td>
<td>Rama</td>
<td>Mysore</td>
<td>08212569964</td>
</tr>
<tr>
<td>Pratap</td>
<td>S</td>
<td>Bangalore</td>
<td>08025689754</td>
</tr>
<tr>
<td>Shrinivas</td>
<td>G</td>
<td>Mercara</td>
<td>08965445454</td>
</tr>
</table>
</body>
</html>

Set 13


//1. Write C Program to create Indian Flag.
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
const float PI=3.14154;
void main()
{
int gdriver=DETECT,gmode=0;
int I;
Int x,y;
initgraph(&gdriver,&gmode,”c:\\tc\\bgi”);
cleardevice();
rectangle(0,0,639,479);
outtextxy(250,20,”INDIAN FLAG”);
rectangle(80,50,560,380);
line(80,160,560,160);
line(80,270,560,270);
setfillstyle(SOLID_FILL,LIGHTRED);
floodfill(85,60,getmaxcolor());
setfillstyle(SOLID_FILL,WHITE);
floodfill(85,170,getmaxcolor());
setfillstyle(SOLID_FILL,GREEN);
floodfill(85,280,getmaxcolor());
setcolor(BLUE);
circle(320,215,50);
for(I=0;I<=360;I+=15)
{
x=50*cos(I*PI/180);
y=50*sin(I*PI/180);
line(320,215,320+x,215-y);
}
setcolor(CYAN);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,6);
outtextxy(200,400,”    JAI HIND!!!” ) ;
getch();
}

//2. Write C Program to create FISH structure using basic geometric  Functions.
#include<graphics.h>
#include<stdlib.h>
#include<conio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,i,j,p,q,x,y,k,flag;
struct arccoordstype arcinfo;
initgraph(&gd,&gm,”c:\\tc\\bgi”);
y=getmaxy()/2;
i=0;
p=0;
q=0;
j=0;
flag=0;
setcolor(WHITE);
for(k=0;k<500;k++)
putpixel(random(620),random(419),15);
while(!kbhit())
{
line(0+i,y+20,0+i,y-20);  /*triangle*/
line(0+i,y+20,20+i,y);
line(0+i,y-20,20+i,y);
ellipse(80+i,y,10-p,350+p,60,25);
line(140+i,y+3,130+i,y+8);
line(130+i,y+8,140+i,y-5);
if(flag==0)
p=p+2;
if(flag==1)
p=p-2;
circle(120+i,y-6,5);
line(60+i,y-25,30+i,y-45+j);
line(30+i,y-45+j,100+i,y-25);
line(60+i,y+25,30+i,y+45+q);
line(30+i,y+45+q,100+i,y+25);
i=i+3;
if(i>=638)
i=0;
if(flag==0)
j=j-2,q=q+2;
if(flag==1)
j=j+2,q=q-2;
if(j<=-10)
flag=1;
else if(j>=0)
flag=0;
delay(10);
cleardevice();
}
getch();
closegraph();
}

Set 14

//1. Write Open GL Program to create a Window and display HELLO inside.
#include<GL/glut.h>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25,0.25,0.25);
glVertex3f(0.75,0.25,0.0);
glVertex3f(0.75,0.75,0.0);
glVertex3f(0.25,0.75,0.0);
glEnd();
glFlush();
}
Void init(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
}
Int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow(“HELLO”);
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

//2. Create a simple static web page for a college (assume necessary information)
<html>
<head>
<title>My College Site</title>
</head>
<body bgcolor=”gray” text=”white” >
<div id=”banner” style=”width:800px; height:120px; background-color:black”>
<img src=”file:///C:/banner.gif” width=800 height=120></div>
<div id=”header” style=”position:absolute; left:100px; top:30px; width:350px; height:75px”>
<div><h1><font color=”red” face=”Monotype corsiva”>My College Site</font></h1></div>
</div>
<div id=”header” style=”position:absolute; background-color:black; top:135px; width:200px; height:500px”>
<ul id=”listitem” type=”circle”>
<li><a href=abc.html target=”_self”>Home</a></li>
<li><a href=”Sitemap.html”>Sitemap<a></li>
<li><a href=”About.html”>About Us<a></li>
</ul>
</div>
<div id=”header” style=”position:absolute; background-color:black; left:215px; top:135px; width:590px; height:500px”>
<h3><font color=”red”>Online Admission</font></h3>
<form id=”frm1?>
Enter your name: <input type=”text” id=”text1? /> <br/><br/>
Gender: <input type=”radio” id=”gender1? name=”gend” />Male <input type=”radio” id=”gender1? name=”gend” />Female  <br/><br/>
Qualification: Matric<input type=”checkbox” id=”check1? /> Enter<input type=”checkbox” id=”check1? /><br/><br/>
<input type=”reset” value=”Reset” />
<input type=”submit” value=”Submit” post=”” /><br/><br/>
</form>
</div>
</body>
</html>


BSC-IT 6TH SEMESTER PRACTICAL SOLUTION



KU 6TH SEM PRACTICAL SOLUTIONS

Set -1
1. Write a program for frame sorting technique used in buffers.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct frame
{
       int fslno;
       char finfo[20];
};
struct frame arr[10];
int n;
void sort()
{
       int i,j,ex;
       struct frame temp;
       for(i=0;i<n;i++)
       {
              ex=0;
              for(j=0;j<n-i-1;j++)
              if(arr[j].fslno>arr[j+1].fslno)
              {
                     temp=arr[j];
                     arr[j]=arr[j+1];
                     arr[j+1]=temp;
                     ex++;
              }
              if(ex==0) break;
       }
}

void main()
{
       int i;
       clrscr();
       printf(“\n Enter the number of frames \n”);
       scanf(“%d”,&n);
       for(i=0;i<n;i++)
       {
              arr[i].fslno=random(50);
              printf(“\n Enter the frame contents for sequence number %d\n”,arr[i].fslno);
              scanf(“%s”,arr[i].finfo);
       }
       sort();
       printf(“\n The frames in sequence \n”);
       for(i=0;i<n;i++)
       printf(“\n %d\t%s \n”,arr[i].fslno,arr[i].finfo);
       getch();
}

2. Write a program in C# using command line arguments to display a welcome message. The message has to be supplied as input in the command line.
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            args = new string[1];

            Console.Write(“Enter Message Here: “);
            args[0] = Console.ReadLine();

            Console.WriteLine(“\n” + args[0]);
            Console.ReadLine();
        }
    }
}

Set -2
1. Write a program for distance vector algorithm to find suitable path for transmission.
#include<stdio.h>
#define MAX 10
struct dist_vect
{
    int dist[MAX];
    int from[MAX];
};
int main()
{
    int adj[MAX][MAX],n,i,j,hop[10][10]={{0}},k,count;
    struct dist_vect arr[10];
    printf(“Enter the number of nodes\n”);
    scanf(“%d”,&n);
    printf(“Enter adjecency matrix\n”);
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        scanf(“%d”,&adj[i][j]);
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            arr[i].dist[j]=adj[i][j];
            arr[i].from[j]=j;
        }
    }
    count=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            for(k=0;k<n;k++)
            {
                if(arr[i].dist[j]>adj[i][k]+arr[k].dist[j])
                {
                    arr[i].dist[j]=adj[i][k]+arr[k].dist[j];
                    arr[i].from[j]=k;
                    count++;
                    if(count==0)hop[i][j]=1;
                    else hop[i][j]=count+hop[k][j];
                }
            }
            count=0;
        }
    }
    for(i=0;i<n;i++)
    {
        printf(“State value of router under %d”,i+1);
        printf(“\nNode\tvia node\tdistance\tnumber of hops\n”);
        for(j=0;j<n;j++)
        {
            if(i==j)
            printf(“\n%d\t%d\t%d\n”,j+1,arr[i].from[j]+1,arr[i].dist[j]);
            else
            printf(“\n%d\t%d\t\t%d\t\t%d\n”,j+1,arr[i].from[j]+1,arr[i].dist[j],hop[i][j]+1);
        }
    }
}

2. Write a program to demonstrate the usage of threads in C#.
using System;
using System.Threading;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main()
        {
            Thread thread1 = new Thread(new ThreadStart(A));
            Thread thread2 = new Thread(new ThreadStart(B));
            thread1.Start();
            thread2.Start();
            thread1.Join();
            thread2.Join();
        }

        static void A()
        {
            Thread.Sleep(100);
            Console.WriteLine(‘A’);
        }

        static void B()
        {
            Thread.Sleep(1000);
            Console.WriteLine(‘B’);
        }
    }
}

Set -3
1. Write a program for simple RSA/DES algorithm to encrypt and decrypt the data.
#include<stdio.h>
#include<math.h>
double min(double x, double y)
{
    return(x<y?x:y);
}
double max(double x,double y)
{
    return(x>y?x:y);
}
double gcd(double x,double y)
{
    if(x==y)
    return(x);
    else
    return(gcd(min(x,y),max(x,y)-min(x,y)));
}
long double modexp(long double a,long double x,long double n)
{
    long double r=1;
    while(x>0)
    {
        if ((int)(fmodl(x,2))==1)
        {
            r=fmodl((r*a),n);
        }
        a=fmodl((a*a),n);
        x/=2;
    }
    return(r);
}
int main()
{
    long double p,q,phi,n,e,d,cp,cq,dp,dq,mp,mq,sp,sq,rp,rq,qInv,h;
    long double ms,es,ds;
    do
    {
        printf(“\n Enter prime numbers p and q:”);
        scanf(” %Lf %Lf”,&p,&q);
    }
    while(p==q);
    n=p*q;
    phi=(p-1)*(q-1);
    do
    {
        printf(“\n Enter prime value of e:”);
        scanf(” %Lf”,&e);
    }
    while((gcd(e,phi)!=1)&&e>phi);
    for(d=1;d<phi;++d)
    {
        if(fmod((e*d),phi)==1)
        break;
    }
    printf(“\n D within main = %Lf”,d);
    printf(“\n Enter the message:”);
    scanf(” %Lf”,&ms);
    es=modexp(ms,e,n);
    ds=modexp(es,d,n);
    printf(“\n Original Message : %Lf”,ms);
    printf(“\n Encrypted Message : %Lf”,es);
    printf(“\n Decrypted Message : %Lf\n”,ds);
    return(0);
}

2. Using Try, Catch and Finally blocks write a program in C# to demonstrate error handling.
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, j, divide = 0;
            i = 10;
            j = 0;

            try
            {
                divide = i / j;
            }
            catch (DivideByZeroException)
            {
                divide = 0;
            }
            finally
            {
                Console.WriteLine(divide);
            }
            Console.ReadLine();
        }
    }
}

Set -4
1. Write a program for Spanning Tree Algorithm (PRIM) to find loop less path.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 20
#define INFINITY 999
#include<conio.h>
enum boolean {FALSE,TRUE};
void prim(int c[][MAX],int t[MAX],int n);
int mincost=0;
int main()
{
    int n,c[MAX][MAX],t[2*(MAX-1)];
    int i,j;
    clrscr();
    printf(“\nTo find min path spanning tree”);
    printf(“\nEnter no of nodes:”);
    scanf(“%d”,&n);
    printf(“\nEnter the cost adjacency matrix”);
    for(i=0;i<n;i++)
    for(j=0;j<n;j++)
    scanf(“%d”,&c[i][j]);
    prim(c,t,n);
    for(i=0;i<2*(n-1);i+=2)
    printf(“\n(%d %d)”,t[i]+1,t[i+1]+1);
    printf(“\nmincost=%d”,mincost);
    getch();
    return 0;
}
//using prim’s algorithm for finding shortest path
void prim(int c[][MAX],int t[MAX],int n)
{
    int i,j;
    enum boolean v[MAX];
    int k,s,min,v1,v2;
    for(i=0;i<n;i++)
    v[i]=FALSE;
    v[0]=TRUE;
    k=0;
    t[k]=1;
    s=0;
    k++;
    while(k<n)
    {
        min=INFINITY;
        for(i=0;i<n;i++)
        for(j=1;j<n;j++)
        if(v[i]==TRUE && v[j]==FALSE && c[i][j]<min)
        {
            min=c[i][j];
            v1=i;
            v2=j;
        }
        mincost=mincost+min;
        if(min==INFINITY)
        {
            printf(“graph disconnected”);
            exit(0);
        }
        v[v2]=TRUE;
        k++;
        t[s++]=v1;
        t[s++]=v2;
    }
}

2. Write a program in C# to demonstrate operator overloading.
using System;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main()
        {
            Widget w = new Widget();
            w++;
            Console.WriteLine(w._value);
            w++;
            Console.WriteLine(w._value);

            Widget g = new Widget();
            g++;
            Console.WriteLine(g._value);

            Widget t = w + g;
            Console.WriteLine(t._value);
        }
    }
    class Widget
    {
        public int _value;

        public static Widget operator +(Widget a, Widget b)
        {
            Widget widget = new Widget();
            widget._value = a._value + b._value;
            return widget;
        }

        public static Widget operator ++(Widget w)
        {
            w._value++;
            return w;
        }
    }
}

Set -5
1. Write a program in C# to sort the students list based on their names. The students list is stored in a string array.
using System;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] students = { ”Vikash”, ”Bhushan”, ”Deepak”, ”Tapas”, ”Suresh”, ”Avinash” };
            Array arr = students;
            Array.Sort(arr);

            foreach (string item in arr)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();
        }
    }
}

2. Write a C# Program to demonstrate use of Virtual and override Key words in C#.
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            ChildClass cc = new ChildClass();
            cc.Display();
            Console.ReadLine();
        }
    }
    class ParentClass
    {
        public virtual void Display()
        {
            Console.WriteLine(“Base Class”);
        }
    }
    class ChildClass:ParentClass
    {
        public override void Display()
        {
            base.Display();
            Console.WriteLine(“Derived Class”);
        }
    }
}

Set -6
1. Write a program in C# , create a class called rectangle which consists of members side_1, side_2 and displayArea(). Write another class square which inherits class rectangle. Take side of square as input and display the area of square on console
using System;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            square sq = new square();
            sq.displayArea();
            Console.ReadLine();
        }
    }
    class rectangle
    {
        public int side_1 = 10;
        public int side_2 = 20;

        public virtual void displayArea()
        {
            Console.WriteLine(“Area of Rectangle is: “ + side_1 * side_2);
        }
    }
    class square:rectangle
    {
        public override void displayArea()
        {
            Console.WriteLine(“Area of Square is: “ + side_1 * side_1);
        }
    }
}


2. Write a program to multiply two matrices.
#include<stdio.h>
int main(){
  int a[5][5],b[5][5],c[5][5],i,j,k,sum=0,m,n,o,p;
  printf(“\nEnter the row and column of first matrix”);
  scanf(“%d %d”,&m,&n);
  printf(“\nEnter the row and column of second matrix”);
  scanf(“%d %d”,&o,&p);
  if(n!=o){
      printf(“Matrix mutiplication is not possible”);
      printf(“\nColumn of first matrix must be same as row of second matrix”);
  }
  else{
      printf(“\nEnter the First matrix->”);
      for(i=0;i<m;i++)
      for(j=0;j<n;j++)
           scanf(“%d”,&a[i][j]);
      printf(“\nEnter the Second matrix->”);
      for(i=0;i<o;i++)
      for(j=0;j<p;j++)
           scanf(“%d”,&b[i][j]);
      printf(“\nThe First matrix is\n”);
      for(i=0;i<m;i++){
      printf(“\n”);
      for(j=0;j<n;j++){
           printf(“%d\t”,a[i][j]);
      }
      }
      printf(“\nThe Second matrix is\n”);
      for(i=0;i<o;i++){
      printf(“\n”);
      for(j=0;j<p;j++){
           printf(“%d\t”,b[i][j]);
      }
      }
      for(i=0;i<m;i++)
      for(j=0;j<p;j++)
           c[i][j]=0;
      for(i=0;i<m;i++){ //row of first matrix
      for(j=0;j<p;j++){  //column of second matrix
           sum=0;
           for(k=0;k<n;k++)
               sum=sum+a[i][k]*b[k][j];
           c[i][j]=sum;
      }
      }
  }
  printf(“\nThe multiplication of two matrix is\n”);
  for(i=0;i<m;i++){
      printf(“\n”);
      for(j=0;j<p;j++){
           printf(“%d\t”,c[i][j]);
      }
  }
  return 0;
}


Set -7
1. Write a C# program to demonstrate handling of server control programs.
In order to create new ASP.NET Server Control, use File – New – Project from Visual Studio 2008 menu to open the New Project dialog box. From the Web project type, choose ASP.NET Server Control.

Code Behind File For ServerControl1.cs :-

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FirstServerControl
{
    [DefaultProperty(“Text”)]
    [ToolboxData(“<{0}:ServerControl1 runat=server></{0}:ServerControl1>”)]
    public class ServerControl1 : WebControl
    {
        [Bindable(true)]
        [Category(“Appearance”)]
        [DefaultValue(“”)]
        [Localizable(true)]
        public string Text
        {
            get
            {
                String s = (String)ViewState[“Text”];
                return ((s == null) ? ”[” + this.ID + “]“ : s);
            }

            set
            {
                ViewState[“Text”] = value;
            }
        }

        protected override void RenderContents(HtmlTextWriter output)
        {
            output.Write(Text);
        }
    }
}

2. Write a program to display a message “Welcome to ASP.NET” 8 times in increasing order of their font size using ASP.NET.
<%@ Page language=”c#” Codebehind=”WebForm1.aspx.cs”
AutoEventWireup=”false” Inherits=”WebApplication9.WebForm1? %>
<!DOCTYPE HTML PUBLIC ”-//W3C//DTD HTML 4.0 Transitional//EN” >
<html>
    <head>
        <title>WebForm1</title>
        <meta name=”GENERATOR” Content=”Microsoft Visual Studio .NET 7.1?>
        <meta name=”CODE_LANGUAGE” Content=”C#”>
        <meta name=vs_defaultClientScript content=”JavaScript”>
        <meta name=vs_targetSchema
        content=”http://schemas.microsoft.com/intellisense/ie5?>
    </head>
    <body MS_POSITIONING=”GridLayout”>
        <form id=”Form2? method=”post” runat=”server”>
            <%for(int i=0;i<8;i++){%>
                <font size=”<%=i%>”>Welcome to ASP.NET ASHISH</font><br/></font>
            <%}%>
        </form>
    </body>
</html>