final of programming

39
International Diploma in Computer Studies Programming Methods Statement and Confirmation of Own Work Programme/Qualification name: International Diploma in Computer Studies Each NCC Education assessed assignment submitted by you must have this statement attached to the assignment as the cover page or it will not be accepted for marking. Please ensure that this statement is either firmly attached to the cover of the assignment or electronically inserted into the front of the assignment. Student declaration I have read and understood NCC Education’s policy on Academic Dishonesty and Plagiarism. I can confirm the following details: Student ID/Registration number: 100028 / 00122348 Name: Sunoj Shrestha Centre Name: Module Name: PROGRAMMING METHODS Module Leader: Number of words: 1

Upload: savin-sharma

Post on 03-Apr-2015

1.382 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: final of programming

International Diploma in Computer Studies Programming Methods

Statement and Confirmation of Own Work

Programme/Qualification name: International Diploma in Computer Studies

Each NCC Education assessed assignment submitted by you must have this statement

attached to the assignment as the cover page or it will not be accepted for marking. Please

ensure that this statement is either firmly attached to the cover of the assignment or

electronically inserted into the front of the assignment.

Student declaration

I have read and understood NCC Education’s policy on Academic Dishonesty and Plagiarism.

I can confirm the following details:

Student ID/Registration number: 100028 / 00122348

Name: Sunoj Shrestha

Centre Name:

Module Name: PROGRAMMING METHODS

Module Leader:

Number of words:

I confirm that this is my own work and that I have not plagiarized any part of it. I have also noted

the assessment criteria and pass mark for assignments.

Due Date:

Student Signature:

Submitted Date:

1

Page 2: final of programming

International Diploma in Computer Studies Programming Methods

Acknowledgment

2

Page 3: final of programming

International Diploma in Computer Studies Programming Methods

TABLE OF CONTENT

Statement of confirmation of own work 1

Acknowledgement 2

Table of content 3

Task 1 4-15

Task 2 16-17

Task 3 18-21

Task 4 22-27

Task 5 28-39

Task 6 40

Task 7

Task 8

Bibliography Referencing 41

3

Page 4: final of programming

International Diploma in Computer Studies Programming Methods

Data Structured Diagrams (DSDs )

……………………………………………………………………………………………………………….

Step 1(DSD) of top-down development – stepwise progression for Report 1

……………………………………………………………………………………………………………….

Step 2(DSD) of top-down development – stepwise progression for Report 1

4

Header Body Footer

Member *

Paid ° /°

List of Paid up members of

Badminton Club

Header Body Footer

List of Paid up members of

Badminton Club

Page 5: final of programming

International Diploma in Computer Studies Programming Methods

……………………………………………………………………………………………………………….

Step 3(DSD) of top-down development – stepwise progression for Report 1

5

Member *

Paid ° /°

List of Paid up members of

Badminton Club report

Header Body Footer

Member type °

section

Member line° Section total°

Number Name Contact

Page 6: final of programming

International Diploma in Computer Studies Programming Methods

Program Structure Diagram (PSD)

……………………………………………………………………………………………………………….

Step 1(PSD) of top-down development – stepwise progression for Report 1

……………………………………………………………………………………………………………….

Step 2(PSD) of top-down development – stepwise progression for Report 1

6

List of Paid up members

of Badminton Club

Opening Processing Closing

Process File Closing all

Files

Opening input

files

Opening

output files

Output Closing

Message

List of Paid up members

of Badminton Club

Opening Processing Closing

Page 7: final of programming

International Diploma in Computer Studies Programming Methods

7

Name Contact number

Add each*

member

Name

Contact number

Add each *

member

Process File Closing all

Files

Opening input

files

Opening

output files

Output Closing

Message

List of Paid up members of

Badminton Club

Opening Processing Closing

Print Member type °

Section

Member Detail Total Member

Process each record *

Junior member°

Member Detail Total Member

Adult member°

Page 8: final of programming

International Diploma in Computer Studies Programming Methods

……………………………………………………………………………………………………………….

Step 3(PSD) of top-down development – stepwise progression for Report 1

PROGRAM SPECIFICATION FOR (TASK 1) REPORT 1

CLIENT NAME : Badminton Club

PURPOSE : This programme produces a report of the list of all Paid-up

Members including Names, Contact Number and Total for each

member level.

PROGRAMMER : Sunoj Shrestha

DUE DATE :

HOW THE PROGRAMME WORKS

This programme is expected to Initialize, Process and Close. This would be based on the

processing. The program will be carried out in three phases. Namely INITIALIZING,

PROCESSING, and CLOSING.

INITIALIZING: All files (input and output) are opened, read from and written to at this stage.

The program will initialize and the total is initializing to zero.

PROCESSING: At this stage the running of the program are shown at this stage. The program

then reads the files of the Members one after the other then print the name, contact Number

and accumulate total of each Membership level by adding individual payments. This process

will continue until End Of File.

CLOSING: The total of the paid up members are printed by the various levels. Open files are

closed and the closing message is shown here.

INPUT: The Club Secretary will first have access to the work files in order to run the program.

8

Page 9: final of programming

International Diploma in Computer Studies Programming Methods

OUTPUT: The structure of the output for all level will be in a tabular format as shown below.

Adult level paid up members

Record details

Name Contact Number Member Count

Raj 9851065757 1

Leon 9841792020 1

Sammer 9851065456 1

Total Member Count 3

Junior level paid up members

Record details

Name Contact Number Member Count

Arjun 9851789234 1

Manish 9841234345 1

Zaved 9851011435 1

Total Member Count 3

Non-Players level paid up members

Record details

Name Contact Number Member Count

Bike 9841677661 1

Ruke 9856532562 1

Parek 9851005644 1

Total Member Count 3

9

Page 10: final of programming

International Diploma in Computer Studies Programming Methods

Data Structured Diagrams (DSDs )

……………………………………………………………………………………………………………….

Step 1(DSDs) of top-down development – stepwise progression for Report 2

……………………………………………………………………………………………………………….

Step 2(DSDs) of top-down development – stepwise progression for Report 2

10

List of Fixtures Team of Badminton Club

Header Body Footer

List of Fixtures Team of Badminton Club

FooterBodyHeader

Level *

1st Team ° 2nd Team ° Junior °

Page 11: final of programming

International Diploma in Computer Studies Programming Methods

……………………………………………………………………………………………………………….

Step 3(PSDs) of top-down development – stepwise progression for Report 2

11

Level *

1st Team ° 2nd Team °

List of Fixtures Team of Badminton Club

Header Body Footer

2nd Team °

Detail of each

amtch

Total

wons

Total Lost

Detail of each match

Total wons Total Lost

Add each

won

Detail of each match

Total wons Total Lost

Add each

won

Detail of each match

Add each

won

Page 12: final of programming

International Diploma in Computer Studies Programming Methods

PROGRAM SPECIFICATION FOR (TASK 1) REPORT 2

CLIENT NAME : Badminton Club

PURPOSE : This programme produces a report of the list of each team Section

In Fixture Line and Team Total order including their number

matches won and lost, and lists of each fixture.

PROGRAMMER : Sunoj Shrestha

DUE DATE :

HOW THE PROGRAMME WORKS

This programme is expected to Initialize, Process and Close. This would be based on the

processing. The program will be carried out in three phases. Namely INITIALIZING,

PROCESSING, and CLOSING.

INITIALIZING: Here the program open all files and initialize total matches to zero. The program

initialization is done in this stage

PROCESSING: At this stage the running of the program are shown at this stage. The program

then reads the files of the team’s one after the other process the number of matches won, lost

opposite, Date and Team total. This process will continue Until End Of File.

CLOSING: All files that were open are closed and List are printed.

INPUT: The Club Secretary will first have access to the work files in other to run the program.

12

Page 13: final of programming

International Diploma in Computer Studies Programming Methods

OUTPUT: The structure of the output for all level will be in a tabular format as shown below.

League Fixture

Record details

Date Own

Player

Opposition

Player

Won Scored Lost Scored

2010/02/03 A B 4 5

2010 A C 5 6

2010 A B 2 8

2010 B A 3 3

2010 B C 4 4

2010 B A 5 3

2010 C A 2 7

2010 C B 3 6

2010 C A 3 9

Total 31 41

13

Page 14: final of programming

International Diploma in Computer Studies Programming Methods

TASK TWO (2)

FLOWCHART FOR REPORT ONE (1)

Yes

No

No

Yes

No

14

Figure 1Figure

Print Report Header

Open Files

Is EOF ?

Is

current

memberIs adult?

Save junior member

number

Save junior member

name

Save junior member

Contact number

Add 1 to junior Total

Print report

body

Print report footer

Close files

End

Save Adult

number

Save Adult

name

Save Adult

Contact

number

Add 1 to Adult

Total

Read Record

Page 15: final of programming

International Diploma in Computer Studies Programming Methods

FLOWCHART FOR REPORT TWO (2)

Yes

No

15

Start

Print Report Header

Open Files

Is EOF ?

Read member record

Save Fixtures date

Save team played

Save opposition

Save match own

Save match lost

Add1, Total Match

Print Report Body

Print Report Footer

Close all Files

End

Page 16: final of programming

International Diploma in Computer Studies Programming Methods

TASK 3

A) PSEUDOCODE FOR PROCEDURE TO CHECK FOR THE PAID-UP MEMBERS

RECORD paid-up members

HAS FIELDS:

Name: String

Contact number: String

Level: String

Payment Detail: String

Member_list [150]:ARRAY OF TYPE members

c, Acount, Jcount OF TYPE Integer Letter OF TYPE String

Use Variable:

Display ”1 Accept Value”

Display “2 Display Report ”

If choice=1 THEN Acc value

Else if choice=2 THEN PreReport

END IF

PROCEDURE Acc value

Use Variable C of type Intger

REPEAT

Count++

Display ”Enter level”

Accept member [count]. Level

16

Page 17: final of programming

International Diploma in Computer Studies Programming Methods

Accept member [count].Number

Accept member [count].Name

Accept member [count].Contact

Accept member [count].Payment Detail

Display ”Do you want to enter more? Press 1 for Yes and 2 For No ”

Accept

Unit (C=2)

END PROCEDURE

PROCEDURE PRI Report

Use Variable: C1=0 of TYPE INTEGER FOR (i=0, i=count, i++)

If member (i). level= Adult and Amount paid=”200”

Display member [i]: name

C1++

End if

End For

PRINT “The total for adult paid-up members is” C1=0

--The loop to display Junior paid-up members

DISPLAY “List of paid-up members”

Use Variable: C2=0 of TYPE INTEGER FOR (i=0, i=count , i++)

If member (i) . level=junior and Amount paid=”100”

Display member [i]: name

C1++

17

Page 18: final of programming

International Diploma in Computer Studies Programming Methods

End if

End For

PRINT “The total for junior paid-up members is” Jcount

ENDPROCEDURE

Recorrection needed

C) PSEUDOCODE FOR REPRT MAIN MENU

- - Main program calling the procedure Report_Type which will display choices

PROGRAM Main_menu

Use variables: choice OF TYPE String

Report_Type

END PROGRAM

- - The procedure Main_menu displaying prompts for the user

PROCEDURE Report_Type

DISPLAY “Choose any one of the following”

DISPLAY “Report1: listing of all paid-up members”

DISPLAY “Report2: listing of all players for each team”

ACCEPT choice

ENDPROCEDURE

- - Calling procedure according to choice of user

18

Page 19: final of programming

International Diploma in Computer Studies Programming Methods

IF choice = Report 1

THEN DISPLAY members

ENDIF

IF choice = Report 2

THEN DISPLAY players

ENDIF

19

Page 20: final of programming

International Diploma in Computer Studies Programming Methods

TASK 4

TEST PLAN FOR REPORT 1 (ONE)

Test

Purpose

This test is to check if the Pseudocode written for Report 1(One) works to generate a list of all paid

members grouped by membership type

Test Data

The data needed to do this test is the membership type which will be residing in the database and

contains the variables: member_ name, member_number, address, contact_telephone_number,

membership_level, date_payment and amount paid.

Test

Condition

A database should be available to contain all the necessary fields needed in the report.

Expected

Outcome

The outcome of the program is expected to be a relational form as follows:

Adult Members Count Junior Members Count

Nam Contac

t

Count

Na

me

Conta

ct

Count

9851065757 1 Arjun 9851789234 1

9841792020 1 Manish 9841234345 1

Sammer 9851065456 1 Zaved 9851011435 1

T

otal Member count 3

Total Member count 3

20

Page 21: final of programming

International Diploma in Computer Studies Programming Methods

Actual

outcome

On running the codes in a dynamic test, the actual output of the program was found to be the same as

that which was expected

Adult Member Count Junior Members Count

Name Contact Count Name Contact Count

9851065757 1 Arjun 9851789234 1

9841792020 1 Manish 9841234345 1

Sammer 9851065456 1 Zaved 9851011435 1

Total Member

count

3

Total Member count 3

Therefore, the program worked well

21

Page 22: final of programming

International Diploma in Computer Studies Programming Methods

DESK CHECK OF PSEUDOCODE FOR REPORT 1 (ONE)

1. Variable List

All the following variables have been checked and found that they were properly declared at the

beginning of the Pseudocode and that they are of the correct data type.

Variable Data Type

Name String

Paid Boolean

Contact_telephone_number Integer

22

Page 23: final of programming

International Diploma in Computer Studies Programming Methods

Address String

membership_level String

club[150] A record type ARRAY

Count Integer

Acounts Integer

Jcount Integer

Password String

2. Constants

There were no constants

3. Variable Equation

Variable member_level was equated to annual

Variable paid was equated to true

Variable club[s] .level was equated to annual

Variable club[s] .paid was equated to true

Variable club[s] .member_level was equated to adult

Reference:

Desk Check Guide, n.d

23

Page 24: final of programming

International Diploma in Computer Studies Programming Methods

DRY RUNNING FOR REPORT 1 (ONE)

The purpose of dry running is for the programmer to walk through the codes and execute them

manually to verify if the outcome will be as expected. In the table below, the code for report 1 is

dry run and it shows how the variables will change as the codes run. Note that the total variable

is not counted when the membership type is monthly and not yearly. Since it is impossible to run

the entire loop, only four passes have been run.

Pass S club[s] .lev

el

club[s] .pai

d

club[s] .nam

e

club[s] .contac

t

club[s] .addres

s

adult_total

1st

pass

s:=1 Adult True Raj 9851065757 16 Balaju 1

24

Page 25: final of programming

International Diploma in Computer Studies Programming Methods

2nd

pass

s:=2 Junior True

3rd

pass

s:=3 Adult True Leon 9841792020 8 Metdevi 2

4th

pass

s:=4 junior True

Paid Members Program

This loop closes for adult membership and the s variable is initialized again to set it in readiness

for the club array of members.

Note that the total variable is not counted when the membership type monthly and not yearly. This wills

also the same format.

Pass S club[s] .lev

el

club[s] .pai

d

club[s] .nam

e

club[s] .conta

ct

club[s] .address adult_total

1st

pass

s:=1 adult True Raj 9851065757 16 Balaju 1

2nd

pass

s:=2 junoir True

3rd

pass

s:=3 adult True Leon 9841792020 8 Metdevi 2

4th

pass

s:=4 junoir True

Note that in the second pass and fourth pass the variables for members name and contact are

empty because the conditions for type and paid fields were not satisfied.

Reference:

Structured Programming Methods (Page 6-16)

25

Page 26: final of programming

International Diploma in Computer Studies Programming Methods

TEST PLAN FOR REPORT 2 (TWO)

Test Purpose

This test is to check if the Pseudocode written for Report 2(two) works to generate a list of all

players for each of the four teams by matches played.

Tes

t Data

The data needed to do this test is the membership file which will be in the database and

includes all records as well as well as variables needed in the report.

Test Condition

A database should be available to contain all the necessary fields needed in the report.

26

Page 27: final of programming

International Diploma in Computer Studies Programming Methods

Ex

pected Outcome

The outcome of the program is expected to be a relational form as follows:

1.Team Fixture played 2.Team Fixture played

Team Won

Matches

played

Total scored Team Lost

Matches

played

Total

scored

A 15 21 A 20 22

B 20 24 B 19 36

C 18 20 C 4 36

Total score:

65 Total score: 94

Actual outcome On running the codes in a dynamic test, the actual output of the program was found to be the same as that which was expected

1.Team Fixture played

2.Team Fixture played

Team Won

Matches

played

Total scored Team Lost Matches played

Total scored

A 15 21 A 20 22

27

Page 28: final of programming

International Diploma in Computer Studies Programming Methods

B 20 24 B 19 36

C 18 20 C 4 36

Total 65 Total 94

Therefore, the program worked well

Reference:Structured Programming Methods (2001, p.6-27)

28

Page 29: final of programming

International Diploma in Computer Studies Programming Methods

TASK SIX (7)

REVIEW, ASSUMPTIONS AND POSSIBLE CHANGES

Task one consists of a report on members who have paid and list of players with details matches played. These reports were produced using logical Data Structure Diagrams (DSD) and Program Data Structure (PSD) showing the stepwise progressions involved. Program Specification reports were also produced for both reports.

Task two is a flowchart for both reports specified in task one. In task three, a procedure to check for paid members is produced, a Pseudocode for report 1 and 2 in task one and a Pseudocode for report main menu is produced. In task four, Pseudocode written in task three are tested by producing a test plan, desk checks and dry runs. In task five UMLs are used. A high-class diagram is created for the club’s system, a high-level USE CASE analysis and USE CASE diagrams produced. SEQUENCE and COLLABORATION diagrams for the USE CASE scenarios produced.

It was assumed the files already exist and so is the database behind the program. This was used throughout the assignment precisely Task 2 and 3.Therefore there was no need to enter the entire information of members of the club.

29

Page 30: final of programming

International Diploma in Computer Studies Programming Methods

The number of members of the club was assumed to be 100 in the flowchart and Pseudocode for Report 1 and 3. Therefore the loop will only run from 1 to 150. Since that was the size of the array containing the member’s details (club [150]).According to (Structured Programming Methods, 2001) the size of the database can be increased or decreased as entries are added or deleted. This database was assumed to be a relational one since this kind of implementation is easier to work with. This is known as a flexible and easy to query database (Shelly Cashman & Rosenblatt, 1998)

To check if a members has paid or not, another field was introduced into the clubs database structure. This was done by introducing the “paid” field which is a variable of Boolean data type.

Work could have been improved by the introduction of CRC cards in the production of reports and class diagrams in this assignment as shown on the site (CRC white papers, n.d). CRC which stands for Class, Responsibility and Collaboration are cards that are used to identify the various objects and classes in a system (Structured Programming Methods, 2001).Producing a CRC card is done through a brain storming session where system experts and domain experts are gathered each asked his views of the system. These views are then filtered and final output of CRC card is produced.

The systems in this assignment are model using UML techniques. According to Martin Fowler (2004), state diagrams could also be used in modelling the systems. State diagrams, shows the various states or stages through which an object goes through in a system.

Activity Diagrams could also be used for this system. Activity Diagrams keep track of the various activities in a system as well as the decision points in the system (Structured Programming Methods, 2001, P.5-50).Almost all the other techniques lack these illustration.

BIBLOGRAGHY AND REFERENCINGBOOKS

Programming Methods 2008, NCC Education Limited Publisher, UK.

Ambler, S 2004a, The Object Primer: Agile Model-Driven Development with UML 2.0, 3 rd

Edition, Cambridge University Press, UK

Ambler, S 2004b, The Object Primer: Agile Model-Driven Development with UML 2.0, 3 rd

Edition, Cambridge University Press, UK.

Craig, L 1997, Applying UML and Patterns, Prentice Hall PTR.

WEBSITES

Jackson Structured Programming n.d.,

Retrieved February 30, 2008, from

http://en.wikipedia.org/wiki/Jackson Structured Programming

30

Page 31: final of programming

International Diploma in Computer Studies Programming Methods

Introduction to Object-Orientation and the UML 2007

Retrieved April 6, 2008 from

http://www.agiledata.org/essays/objectOrientation101.html#UML

UML Sequence Diagram 2006

Retrieved on April 6, 2008

http://www.agiledata.org/essays/objectOrientation101.html#UMLSequenceDiagrams

The Elements of UML 2.0 Style 2007

Retrieved April 6, 2008 from

http://www.ambysoft.com/books/elementsUMLStyle.html

Pseudocode

Retrieved April 6, 2008 from

http://en.wikipedia.org/wiki/Pseudocode

31

Page 32: final of programming

International Diploma in Computer Studies Programming Methods

32