Download - Software Lab

Transcript
Page 1: Software Lab

Software Laboratory

Group: A JAVA PROGRAMMINGSr. No.

Name Of Experiment

1 Program to implement Object Oriented features.A. Write a program to create student database to implement OO features such as: Class,

Object, Method, String, Vector, Exception Handling etc.B. Write a program to implement Multilevel Inheritance with access specifiers for

calculation of Employee salary on daily basis for both teaching and non-teaching staff.2 Write a simple Applet to illustrate event handling with interactive radio buttons to control

font style of a text field. Also provide a text box wherein the user may enter font size.3 Write a program to display an animated clock that shows day, date and time using

multithreading.4 Write a program to retrieve data from some database table using JDBC.5 Write a program to implement simple Echo server using Sockets programming.Group: A LISP PROGRAMMING1 Write a program in LISP to sort elements of array. (All Sorting Techniques)2 Write program in LISP to implement Line editor.Group: B SYSTEM PROGRAMMING1 Write a program to implement subset of an assembler for 8 or 16 bit microprocessor by

designing suitable data structure.2 Write a program to implement subset of a macro processor.3 Write a program to demonstrate DOS memory management mechanism.

A. Program to implement job scheduling algorithms

1. FCFS

2. SJF

3. Priority

4. Round Robin

B. Program to implement paging simulation using LRU algorithm.4 Write Dynamic Link Library and test it. (Use VB or VC++).5 Design and implement any simple application using Word/Excel Macros.6 Using windows API develop any simple application such as Getting and Setting Windows

Information, System Colors, Running a Program/Files, Shutting down Windows.

Group: C .NET C# PROGRAMMING1 Write a Simple C# program to compute future amount for given return for investment.2 Write a program to demonstrate the creation and use of custom attributes and other features

of c# (Multilevel Inheritance in C#).

1

Page 2: Software Lab

Software Laboratory

3 Write a program to demonstrate the use of delegates, callbacks, and synchronous and asynchronous method invocation.

Group: A JAVA PROGRAMMING

2

Page 3: Software Lab

Software Laboratory

Assignment No. – 1.A

Aim: - Write a program to create student database to implement Object Oriented features such

as: Class, Object, Method, String, Vector, Exception Handling etc.

Steps:

1. Define a class that declares data types to store student information. (Data types like

strings are used to store student name, address, branch, subject names etc.)

2. Define another class which will inherit the first class as well defines methods to

perform operations on student information. It defines menu to perform different

operations on Student record such as: ADD Record, Display, Search, Update,

Delete etc.

3. Second class creates a vector that stores instance (objects) of first class with new

student record. Vector Provide different inbuilt functions like elementAt,

addElement, removeAll etc. using them we can perform any operation on Vector.

4. Second class also defines Main method. In this class make object of the classes and

access the variables defined in classes. Then performs specified operation using that

objects.

Conclusion :

3

Page 4: Software Lab

Software Laboratory

Assignment No. – 1.B

Aim: - Write a program to implement Multilevel Inheritance with access specifiers for

calculation of Employee salary on daily basis for both teaching and non-teaching

staff. Use following Structure

Steps:

1 Define all classes as per shown in above fig. that declares data types to store

Employee Information. (Data types like strings are used to store Emp name,

address, branch, ID etc.)

2 Figure shows multiple levels of inheritance. Each class inherits properties of

Parent class including own properties. (using interface we can implement multiple

inheritance).

3 First class defines menu to perform different operations on Employee record such

as: ADD Record, Display, Search, Update, Delete etc. While displaying

information it computes salary of employee from basic salary.

4 First class also defines Main method. In this class make objects of different

classes and access the variables defined in classes. Then performs specified

operation using that objects using different methods defined in classes.

Conclusion :

4

Employee

Non TeachingTeaching

Lecturer(monthly )

Ass. Professor TA

Regular Visiting (Hourly)aid)

Page 5: Software Lab

Software Laboratory

Assignment No. – 2

Aim: - Write a simple Applet to illustrate event handling with interactive radio buttons to

control font style of a text field. Also provide a text box wherein the user may enter

font size.

Steps:

1. Import java.awt.event and java.swing packages.

2. Write a class which will extends Applet class

3. Add text field to read text. Also add text field to read size & combo box to read

different font style from user

4. Add three radio buttons to applet to represent plain text, bold text and italic text.

5. Add one button to change selected font style on click event.

6. Finally write a code for methods to perform specified action.

Conclusion :

5

Page 6: Software Lab

Software Laboratory

Assignment No. – 3

Aim: - Write a program to display an animated clock that shows day, date and time using multithreading.

Steps:

1. Creating threads :

In the most general sense, you create a thread by instantiating an object of type

Thread. Java defines two ways in which this can be accomplished:

You can implement the Runnable interface.

You can extend the Thread class, itself.

2. Implementing Runnable:

The easiest way to create a thread is to create a class that implements the Runnable

interface. Runnable abstracts a unit of executable code. You can construct a thread

on any object that implements Runnable To implement Runnable a class need only

implement a single method called run(), which is declared like this:

Public void run()

3. Extending Thread:

The second way to create a thread is to create a new class that extends Thread and

then to create an instance of that class. The extending class must override the run()

method, which is the entry point for the new thread. It must also call start() to begin

execution of the new thread.

4. Creating Clock:

To create animated clock use Applet and using different properties of Applet we can

create clock.

5. Display Clock:

By accessing system clock we can display animated clock with rotating hands.

Conclusion :

6

Page 7: Software Lab

Software Laboratory

Assignment No. – 4

Aim: - Write a program to retrieve data from some database table using JDBC.

Steps: 1. Loading the driver

Import java.sql packageTo load the driver class.for Name ( ) method is used

Class . for Name ( “ sun . jdbc.odbc.jdbcodbc driver”) ;

When the driver is loaded , it register itself with the java.sql.drivermanager class

as an available database driver

2. Making a connection with database

To open a connection to a given database

driver manager.get Connection ( ) method is used

Connection con = drivermanager.getconnection

( “ jdbc:odbc:somedb”,”user”,”password”);

3. Executing sql statements

To execute a sql query , java sql.statement class is used

Statement stmt = con.createstatement ( )

A query that returns data can be executed using the executequery ( )

Method of statement this method execute the statement and returns java.sql.resultset that

encapsulates the retrieved data

Resultset rs = stmt.executequery (“ SELECT * from some table”);

4. Process the result

Resultset returns one row at a time Next( ) method of the resultset.object can be called to

move the next row the getstring ( ) and get object ( ) methods are used for retrieving

column values

while ( rs.next ( ) )

{string event = rs.getstring ( “event”);

Object.count = (Integer)rs.getobject(“count”);

}

Conclusion :

7

Page 8: Software Lab

Software Laboratory

Assignment No. – 5

Aim: - Write a program to implement simple Echo server using Sockets programming.

Steps:

1. Import java.net package in program.

2. Create Server Socket using socket class with specified port number.

3. Create Client socket with specified IP address which connects to server using

same port number.

4. Write a code for both server and client classes that behaves like Echo server.

5. Client sends connection request to server and once client get connected to

server they communicates each other by sending and receiving messages.

Conclusion :

8

Page 9: Software Lab

Software Laboratory

Group: A LISP PROGRAMMING

9

Page 10: Software Lab

Software Laboratory

Assignment No. –1

Aim: - Write a program in LISP to sort elements of array. (All Sorting Techniques)

Steps:

1. To design the LISP program that uses

FIRST and REST

CAR and CDR

SETF

CONS,APPEND and LIST

LENGTH and REVERSE

ASSOC

Using all above commands we can write code to implement given assignment.

2. Reference :

Chapter 1 and 2 of “ LISP” 3rd edition winston and horn , pearson education

Conclusion :

10

Page 11: Software Lab

Software Laboratory

Assignment No. –2

Aim: Write program in LISP to implement Line editor.

Steps:

1. The program uses the functions of LISP for editor design which has facility

• Insert

• Delete

• Length

• Concatenate

• Reverse

• Search

• append

Using files we can implement line editor in LISP.

Conclusion :

11

Page 12: Software Lab

Software Laboratory

Group: B

SYSTEM PROGRAMMING

12

Page 13: Software Lab

Software Laboratory

Assignment No. – 1

Aim: - Design suitable data structures and develop a subset of an assembler for 8 or 16 bit

microprocessor. Subset should consist of a few instructions from each category and few

assembler directives

Steps:

ALGORITHM OF ASSEMBLER

THEORY:-

1. Imperative statement.

2. Declarative statement.

3. Assembler directive statement.

Advanced Assembler Directives

Data Structures Used.

1. OPTAB

2. SYMT AB

3. LITTAB

Schematic Diagram of 2 Pass Assembler Flow Chart ofPass I and Pass II.

ALGORITHM:-

Pass - I Algorithm :-

1. loc-cntr := 0;( default value)

2. pooltab-ptr := 1; POOLTAB[I] := 1; lit tab -ptr := I ;

13

Page 14: Software Lab

Software Laboratory

While next statement is not an END Statement a. If label is present then

this-label := symbol in label field:

Enter (this-label , loc-cntr) in SYMTAB. b. If an L TORG statement then i) Process

literals

LITTAB(POOLTAB(pooltab-ptr]]. ..LITTAB(littab-ptr -1 to allocate memory and

put the address in the address field. Update loc-cntr accordingly.

ii) poottab -ptr := poltab -ptr + 1 ;

iii) POOL T AB (pooltab -ptr ] := lit tab -ptr c. If START or ORIGIN statement then

loc-cntr := value specified in operand field. d. If an EQU statement then

i) this-addr := value of <address spec>;

ii) Correct the SYMTAB entry for this-label to (this-label, this-addr) .

e. If a declaration statement then

i) code:=code of declaration statement;

ii) size := size of memory area required by DC/DS. . iii) Loc-cntr := loc-cntr + size.

iv) Generate IC '(DL,code). ,

f If an Imperative statement then

i) code := machine opcode from OPT AB;

ii) loc-cntr := loc-cntr + instruction length from OPT AB. iii) If operand is a literal

then

This-literal := literal in operand field; LITTAB(littab-ptr] := this-literal; lit tab -ptr :=

lit tab -ptr + 1 ; else (i.e operand is a symbol)

this-entry := SYMT AB entry number of operand; Generate IC '(IS, code) (S, this-

entry);

3. (Processing of END statement) a. Perform step 2(b).

b. Generate IC '(AD,O2)'. c. Go to Pass II.

14

Page 15: Software Lab

Software Laboratory

Pass - II Algorithm:

.code-area-address ;= address of code-area pooltab ytr ;= 1 ; loc-cntr := 0;

While next statement is not an END Statement

a. Clear machine code buffer . --

bo Ifan LTORG statement then

i) Process literals

LITT AB [POOL T AB [pooltab -ptr ]] o ..LITT AB[littab -ptr -I ] Similar to

processing of constants in DC statement, ie assemble the literals.

ii) size := size of memory area req for literals; iii) poottab -ptr := poltab -ptr + I ; c. If

START or ORIGIN statement then

i) loc-cntr := value specified in operand field. ii) size := 0;

do If a declaration statement then

i) IfDC statement then Assemble the constant in machine code buffer.

ii) size := size of memory area required by DCIDS. eo If an Imperative statement then

i) Get operand address from SYMTAB or LITTAB ii) Assemble instruction in

machine-code-buffer. iii) Size:= size of instruction. f If size!=O then

i) Move contents of machine-code-buffer to the address code-area-address + loc-cntr;

ii) loc-cntr := loc-cntr + size; (Processing of END statement) a. Perform step 2(b) &

2(!).

b. Write code-area into o/p file.

Conclusion:

15

Page 16: Software Lab

Software Laboratory

Assignment No. – 2

Aim: - Design suitable data structures and develop a subset of a macro assembler for 8 or 16

bit microprocessor. Facilities such as Nested Macro, Labels within Macro, Macro

Parameters, Conditional Macro Expansion, Macro Operators (%, &,<...> etc) to be

supported. Use Turbo Librarian to build and use your library code modules

Steps:

Design of Macro Preprocessor

THEORY:-

Macro Instruction

Macro Definition and Call, Advanced macro facilities.

Schematic diagram of Macro preprocessor Data Structures used.

ALGORITHM:-

I. Processin2 of Macro Definition AIQorithm

Data Structures used PNTAB ] EVNTAB ] SSNTAB MNT

KPDT AB SSTAB MDTAB

Parameter name table

Expansion time variable name table Sequencing symbol name table Macro name

table

Keyword parameter default table Sequencing symbol table Macro definition table

I. SSNTAB-ptr = I PNT AB -ptr = I

2. Process the Macro Prototype statement and form the MNT entry. a) Name = Macro

Name

b) For each positional parameter

i) Enter parameter name in PNT AB [ PNT AB -ptr ] ii) PNTAB-ptr = PNTAB-ptr +1

iii) # PP = #PP +1 c) KPDTP = KPDTP -ptr

16

Page 17: Software Lab

Software Laboratory

d) For each keyword parameter

i) Enter parameter name and default value ( if any) in KPDT AB [ KPDT AB -ptr ]

ii) Enter parameter name in PNT AB [ PNT AB -ptr ] iii) KPDT AB -ptr = KPDT AB

-ptr + 1 iv) PNTAB-ptr = PNTAB-ptr +1 v) # KP = #KP + 1 e) MDTP = MDT -ptr t)

#EV=O

g) SSTP = SST AB -ptr

3 .While Not a :MEND statement

~

~

a) Ifan LCL statement then

i) Enter Expansion time variable name in EVNl

.."

b ) If a model statement then

i) If label field contains a sequencing symbol t

I fsymbol is present in SSNTAB then O = entrv no. in SSNTAB

'< " J..~ ~ Else

Enter symbol in SSNT AB [ SSNT AB -ptr ] Q = SSNTAB-ptr

SSNTAB-ptr = SSNTAB-ptr + 1

SSTAB [ SSTP + q -1] = :rvmT-ptr

ii) For a parameter generate the specification ( p , # n )

iii) For an expansion variable generate the specification ( E , # m ) iv) Record the IC

in :rvmT [ :rvmT-ptr ] v) :rvmT-ptr = :rvmT-ptr + 1 c) If a preprocessor statement

then i) If SET statement

Search each expansion time variable name used in statement in EVNT AB and

generate the specification ( E , # m ) ii) If an AIF or AGO statement then

17

Page 18: Software Lab

Software Laboratory

IF sequencing symbol used in the statement is present in SSNl

then

O = entrv no. in SSNTAB

'< "..~.J ..~. Else

Enter symbol in SSNTAB [ SSNTABJ Q= SSNTAB-ptr + 1

Replace the symbol by ( S, SSTP + Q -1 )

iii) Record the IC in :MDT [ :MDT -ptr ] iv) :MDT -ptr = :MDT -ptr + 1 4) ( MEND

statement )

IfSSNTAB-ptr = 1 ( i.e. SSNTAB is empt) Then

SSTP = 0 .

, Else

SSNTAB-ptr = SSTAB- ptr + SSNTAB~ If #KP=O

hen

~

Conclusion:

18

Page 19: Software Lab

Software Laboratory

Assignment No. – 3.A

Aim: - Write a program to demonstrate DOS memory management mechanism.

Program to implement job scheduling algorithms

1. FCFS

2. SJF

3. Priority

4. Round Robin

Steps:

Theory:

• What is job scheduling and necessity of job scheduling?

• Stack simulation for First come First Serve(FCFS),

• Shortest Job First(SJF) :preemptive and non-preemptive

• Round Robin(RR)

Take the input as arrival time, processes, priority and completion time.

For FCFS the processor is handed over to the process which has

arrived first so keep track of arrival of process.

For RR the processor is handed over to the process for equal

amount of time quantum which is specified by user & if time over

then handed to next process.

For SJF the arrival time for all the processes is compared and the

process with less arrival time has handed over the CPU.

In Preemptive Scheduling the process with less execution time

than the currently allocated process will preempt the current

process but in non preemptive case it does not happen.

Conclusion:

19

Page 20: Software Lab

Software Laboratory

Assignment No. – 3.B

Aim: - Program to implement paging simulation using LRU algorithm using frames.

Steps:

Theory:-

1.What is Least Recently Used Algorithm ?

2. Explain Page fault related to LRU .

3. Benefits of LRU over other replacement algorithm ?

LRU :-

1. Take input as page frames .

2. Process the frames .

3. keep the time as main factor with each page .

4. Replace the page that has not been used for longest period of time.

5. Count the page fault .

6. Analyze the output for different reference string.

Conclusion:

20

Page 21: Software Lab

Software Laboratory

Assignment No. – 4

Aim: - Program to implement Dynamic Link Library using VC++

Steps:

Method 1: Easy VC++, Hard VB1. VC++: Invoke New\Projects\Win32 Dynamic-Link Library. Enter the

directory where you want the VC++ project and the project name (MyFuncsProject in the example).

2. VC++: Invoke New\Files\C++ Source File. Check the Add To Project box. Enter the file name (MyFuncs.cpp in the example).

3. VC++: Enter the function's source code. Use __declspec (note the two

underscores) to export the function's symbol. Use 'extern "C"' to minimize

name mangling by VC++.

// Define DllExport to declare exported symbols.#define DllExport __declspec( dllexport )

// Prototype the function.// Use 'extern "C"' to minimize name mangling.extern "C" DllExport long MyCFunc(long x);

// Define the function.extern "C" DllExport long MyCFunc(long x){ return x * x;

}

4. VC++: Set project options using Project\Settings. On the C/C++ tab, select the Code Generation category. Then change Calling Convention to __stdcall.

5. VC++: Select Build\Set Active Configuration. Select the Release configuration. Repeat step 4 to make the options apply to the release configuration in addition to the debug configuration. Use Build\Set Active Configuration to reselect the debug configuration if desired.

6. VC++: Build the project (press F7 or use the Build menu). This creates the DLL file.

VB: In your Visual Basic program, declare the DLL function using the DLL file's full

path name. The function's name in the DLL file has been slightly mangled by VC++.

The name is an underscore, followed by the name you gave it, followed by "@",

followed by the number of bytes in the function's argument list. In this example the

21

Page 22: Software Lab

Software Laboratory

name is _MyCFunc@4 because the function takes one 4 byte argument (a long

integer).

Private Declare Function MyCFunc Lib _ "C:\VBHelper\VcDll\Method1\Release\MyFuncsProject.dll" _ Alias "_MyCFunc@4" _ (ByVal x As Long) As Long

Private Sub Command1_Click()Dim x As LongDim y As Long

x = CInt(Text1.Text) y = MyCFunc(x) Label1.Caption = Str$(y)

End Sub

*** HINT: To quickly determine the mangled name of the function, find the DLL file in Windows Explorer. Right click on the file and select the "Quick View" command. This presents an editor showing information about the DLL. Page down 2 or 3 pages and you will find a list of exported symbols available in the DLL. One of these will be the mangled function name.

VB: Run the program.

Conclusion:

Assignment No. – 5

22

Page 23: Software Lab

Software Laboratory

Aim: - Design and Implement any simple application using Word/Excel Macros.

Steps:

Software requirements EXCEL AND VISUAL BASICS.

1. Enter number in Excel Sheet and use the summation formula.

2. Go in Tool -> Macro -> Record new macro. Give name to the macro then give any

Short cut key and click OK.

3. Go in Debug -> Run -> Macro -> Edit

You will find code of Macro in VB.

Conclusion:

23

Page 24: Software Lab

Software Laboratory

Assignment No:--6

Aim:- Using windows API develop any simple application such as Getting and Setting Windows Information , System Colors ,Running a Progra/Files , Shutting down Windows.

Steps:-

1) Declare API function.

2) Create API Viewer

a) Select API viewer command from Add-Ins menu. Otherwise select Add-Ins manager.

b) In API viewer window , choose file then load text file then load database file.

c) Select the functions you need for your application and then click the copy button to copy the function declaration to the clipboard.

d) Open your application code window and paste in the function declarations.

2) Use GetWindowDirectory ().which helps to install any initialization files or help files in the windows directory .It’s arguments are lpBuffer and nSsize.

4) Use different functions for System Colors , Running Program / Files and Shutting Down Windows.

Conclusion:

24

Page 25: Software Lab

Software Laboratory

GROUP C

.NET C# PROGRAMMING

25

Page 26: Software Lab

Software Laboratory

Assignment No. – 1

Aim: - Write a Simple C# program to compute future amount for given return for investment.

Steps:

Creation of simple C# application that uses

Literals, variables and data types

Operators and expression

Decision making and branching

– Reference : chapter 1 to 6 of “programming in C#” Balaguruswamy

Conclusion :

26

Page 27: Software Lab

Software Laboratory

Assignment No. – 2

Aim: - Write a program to demonstrate the creation and use of custom attributes and other

features of c# (Multilevel Inheritance in C#).

Steps:

Write a C# application which uses

Methods in C#

Classes and objects

Inheritance and polymorphism

Operator overloading.

– Reference : chapter 12 to 15 of “programming in C#” Balaguruswamy

Conclusion :

27

Page 28: Software Lab

Software Laboratory

Assignment No. – 3

Aim: - Write a program to demonstrate the use of delegates, callbacks, and synchronous and

asynchronous method invocation.and Implement any simple application using

Word/Excel Macros.

Steps:

Write a C# program to demonstrate delegates and event handeling.

Declaration of delegates

Define the delegates

Invocation of the delegates

Multicast delegates

Use the delegates

– Reference : chapter 16 of “programming in C#” Balaguruswamy

Conclusion :

28


Top Related