• No results found

COMPUTER PROGRAMMING FOR BUSINESS (BMGT 121)

N/A
N/A
Protected

Academic year: 2021

Share "COMPUTER PROGRAMMING FOR BUSINESS (BMGT 121)"

Copied!
18
0
0

Loading.... (view fulltext now)

Full text

(1)

COMPUTER PROGRAMMING FOR BUSINESS (BMGT 121)

1. Course outline ...

2. Week1-6: Introduction to computer programming and office automation 2.1. Definition of Programming ...

2.2. IT concepts ...

5.1. Ms Word Advanced ...

5.2. Ms Excel Advanced ...

5.3. Introduction to Ms Access ...

5.3.1. Access Database Objects ...

5.3.2. Data Types ...

5.3.3. Create a Database in MS Access 2007 5.3.4. Access Forms ...

5.3.5. Create Table ...

COMPUTER PROGRAMMING FOR BUSINESS (BMGT 121)

...

6: Introduction to computer programming and office automation ...

...

...

...

...

...

...

5.3.3. Create a Database in MS Access 2007 ...

...

...

COMPUTER PROGRAMMING FOR BUSINESS (BMGT 121)

... 3

6: Introduction to computer programming and office automation ... 4

... 4

... 4

... 10

... 11

... 11

... 11

... 11

... 12

... 12

... 12

(2)

5.3.6. Queries ... 13

5.3.7. Reports ... 13

6. 4. Week7-8: Introduction to computer programming concepts and tools ... 13

6.1. Definition of Key terminologies ... 13

6.2. Flow charting, algorithms and pseudocodes ... 14

6.3. Introduction to computer programming languages ... 16

7. Week 9-13: Visual Basic Programming for Business Application Development ... 17

7.1. Introduction to VB environment and features ... 17

7.2. Form design and Windows Application Forms in VB ... 18

7.3. Coding VB procedures ... 18

7.4. Testing and Debugging ... 18

8. Idea ... 18

(3)

1. Course outline

KABARAK UNIVERSITY

COURSE CODE: BMGT 121

COURSE NAME: COMPUTER PROGRAMMING FOR BUSINESS LECTURER: KAMAU GG

Email: [email protected]

Pre-requisite: None, however knowledge in Introduction to Computers and ICT applications will be a great advantage.

COURSE OBJECTIVES

The objectives of this course are to enable students to :

1. Provide the learner with an opportunity to use computers to solve business and economic problems 2. Develop the learner’s skills in the use of computer applications (word-processing, spreadsheets and

advanced personal productivity skills)

3. Equip learners with end user programming skills using Ms Access to create data entry forms, tables, queries and reports

4. Introduce learners to programming concepts 5. Gain basic computer programming skills

COURSE CONTENT

1. Week1-6: Introduction to computer programming and office automation a. Using Microsoft Word to automate office documents

b. Using Ms Excel for Data Analysis automation

c. Ms Access end user programming (create tables, forms, queries and reports)

2. Week7-8: Introduction to computer programming (computer programming terminologies, types of computer programming languages, software development life cycle. flow charting, programming tools)

3. Week9-13: Visual Basic Programming for Business Application Development

ASSESSMENT

CATS (Individual assignments, group assignment, sit-in CAT) 30%

FINAL EXAM 70%

TOTAL 100%

REFERENCES (Recommended)

Gordon S.R. (2004). Information Systems 3

rd

Ed. Wiley & Sons *

Williams, Brian K et al. (1999). Using Information Technology: A Practical Introduction to Computers &

Communication. Boston: Irwin/McGraw-Hill Inc.

And any other texts on the subject

*Available in the KABU library

(4)

2. Week1-6: Introduction to computer programming and office automation

2.1. Definition of Programming

In ordinary sense a program is a set of instructions to achieve an objective. It is written in a language suitable for the user who then executes its in order to achieve the desired results.

Therefore, computer programming refers to the coding, testing and debugging of some instruction code in a computer understandable language to be executed by the computer. Programming concepts includes study on tools and techniques that programmers use to create new software.

Software development process is a very involving process. Many times software required by a business may be available off-the-shelf for one to buy as need be. However, not all off-the-shelf solutions satisfy the needs of the business. At times the off-the shelf packages may also be expensive and such software does not allow one to modify the code to me their specific needs.

When this is the case then an organization shall have to develop its own software. As a professional worker in an organization you may need to develop your own short term applications to meet some needs before any need to hire a professional. This is called end user programming, which is

programming done by persons who are not ICT programming specialist.

A number of software spossess 2.2. IT concepts

Definition of a computer

A computer is a programmable electronic device that accepts data input to process it using some set of instructions (programs) so as to produce some output information.

Components of a computer system

A computer system comprises of two primary components - Hardware and software.

Hardware refers to the computer physical parts which are further divided into input devices, the central processing unit (CPU), output devices, and storage devices.

Software on the other hand is categorized into systems software and application software.

System software are programs that are required by the computer in order to make it be ready for its functions. They include operating systems and utility programs. Operating systems are programs that are used to support basic computer operations from the time it is powered on until it is shut down. It functions as the platform on which a computer user runs all their user specific programs. Utility programs are variety of programs that can be added to a computer so as to extend functionality of the computer by creating additional functions not necessarily primary to the operating system but give enhanced user environment and some housekeeping functions. For example anti-virus, CD writing software, video player, calculator, etc.

Applications software refer to a variety of programs for user specific tasks. The choice of an application program depends on the type of user and what one wants to do. For example accounting packages, architectural programs, word processing programs, etc.

Assignment: Identify FIVE application programs that can used in a large wholesale business.

Types of computers

(5)

Computers can be categorized as follows;

- Analog vs digital: An analog computer is a form of computer that uses the continuously- changeable aspects of physical phenomena such as electrical, mechanical, or hydraulic quantities to model the problem being solved. In contrast, digital computers represent varying quantities of measurement using discrete values of two digits 0,1 called binary digits. Digital computers are the proper meaning of a computer today.

- Dedicated (special purpose) vs general purpose computer: A dedicated computer is a computing device that is designed by the manufacturer to carry out only one function. It refers to a number of intelligent devices that have some microprocessor to automate them.

For example, electronic fuel pump, ATM machine, electronic washing machine, digital television, etc. General purpose computers on the other are computers that can be

modified to perform any functions by loading the necessary software. Business application computers are general purpose and therefore can be programmed with variety of user applications.

Data Representation inside a computer

All data stored in a computer is coded into binary digits. However, computer data coding can also use a number of other data coding systems including octal and hexadecimal.

Below is some examples to illustrate the arithmetic conversions and operations of these number systems including decimal systems.

3. Binary

• Base or radix 2 number system

• Binary digit is called a bit.

• Numbers are 0 and 1 only.

• Numbers are expressed as powers of 2.

• 2 0 = 1, 2 1 = 2, 2 2 = 4, 2 3 = 8, 2 4 = 16, 2 5 = 32, 2 6 = 64, 2 7 = 128, 2 8 = 256, 2 9 = 512, 2 10 = 1024, 2 11 = 2048, 2 12 = 4096, 2 12 = 8192, …

Conversion of binary to decimal ( base 2 to base 10) Example: convert (110011) 2 to decimal

= (1 x 2 5 ) + (1 x 2 4 ) + (0 x 2 3 ) + (0 x 2 2 ) + (1 x 2 1 ) + (1 x 2 0 )

= 32 + 16 + 0 + 0 + 2 + 1

= (51) 10

Conversion of decimal to binary (base 10 to base 2) Example: convert (51) 10 to binary

51 ÷ 2 = 25 remainder is 1

(6)

25 ÷ 2 = 12 remainder is 1

12 ÷ 2 = 6 remainder is 0

6 ÷ 2 = 3 remainder is 0

3 ÷ 2 = 1 remainder is 1 1 ÷ 2 = 0 remainder is 1

Answer = 1 1 0 0 1 1

Note: the answer is read from bottom (MSB) to top (LSB) as 110011 2

Octal

• Base or radix 8 number system

• 1 octal digit is equivalent to 3 bits.

• Numbers are 0-7.

• Numbers are expressed as powers of 8. 8 0 = 1, 8 1 = 8, 8 2 = 64, 8 3 = 512, 8 4 = 4096.

Conversion of octal to decimal ( base 8 to base 10) Example: convert (632) 8 to decimal

= (6 x 8 2 ) + (3 x 8 1 ) + (2 x 8 0 )

= (6 x 64) + (3 x 8) + (2 x 1)

= 384 + 24 + 2

= (410) 10

Conversion of decimal to octal (base 10 to base 8) Example: convert (177) 10 to octal

177 ÷ 8 = 22 remainder is 1

22 ÷ 8 = 2 remainder is 6

2 ÷ 8 = 0 remainder is 2

(7)

Note: the answer is read from bottom to top as (261) 8 , the same as with the binary case.

Hexadecimal

• Base or radix 16 number system

• 1 hex digit is equivalent to 4 bits.

• Numbers are 0-9, A, B, C, D, E, and F.

• (A) 16 = (10) 10 , (B) 16 = (11) 10 , (C) 16 = (12) 10 , (D) 16 = (13) 10 , (E) 16 = (14) 10 , (F) 16 = (15) 10

• Numbers are expressed as powers of 16.

• 16 0 = 1, 16 1 = 16, 16 2 = 256, 16 3 = 4096, 16 4 = 65536, … Conversion of hexadecimal to decimal ( base 16 to base 10) Example: convert (F4C) 16 to decimal

= (F x 16 2 ) + (4 x 16 1 ) + (C x 16 0 )

= (15 x 256) + (4 x 16) + (12 x 1)

= 3840 + 64 + 12

= (3916) 10

Conversion of decimal to hex (base 10 to base 16) Example: convert (77) 10 to hex

77 ÷ 16 = 4 remainder is D 4 ÷ 16 = 0 remainder is 4

Note: the answer is read from bottom to top as (4D) 16 , the same as with the binary case.

Decimal Binary Octal Hexadecimal

0 0000 0 0

1 0001 1 1

2 0010 2 2

3 0011 3 3

4 0100 4 4

5 0101 5 5

6 0110 6 6

7 0111 7 7

8 1000 10 8

(8)

9 1001 11 9

10 1010 12 A

11 1011 13 B

12 1100 14 C

13 1101 15 D

14 1110 16 E

15 1111 17 F

4. Figure 1 - Table of Binary, Decimal and Hexadecimal Numbers

Conversion of Octal and Hex to Binary

Conversion of octal and hex numbers to binary is based upon the the bit patterns shown in the table above and is straight forward. For octal numbers, only three bits are required. Thus 6 8 = 110 2 , and 345 8 = 11100101 2 . For hex numbers, four bits are required. Thus E 16 = 1110 2 , and 47D 16 = 10001111101 2 .

Conversion of Binary to Octal and Hex

Conversion of binary numbers to octal and hex simply requires grouping bits in the binary numbers into groups of three bits for conversion to octal and into groups of four bits for conversion to hex.

Groups are formed beginning with the LSB and progressing to the MSB. Thus, 11100111 2 = 347 8 and 11100010101010010001 2 = 7025221 8 . Similarly, 11100111 2 = E7 16 and 11000101010000111 2 = 18A87 16 .

5. Binary Arithmetic Binary Addition

+ 0 1

0 0 1

1 1 10

Binary Addition Table

The entry for 1+1 is 10 which indicates a carry of 1

(9)

Examples

Addend 1011 1011 1011 1011 1011

Augend + 100 + 100 + 100 + 100 + 100 Sum 1 11 111 1111

carry 1 1 1 1

Addend 1101 1101 1101 1101 1101 1101

Augend + 1001 + 1001 + 1001 + 1001 + 1001 + 1001 Sum 0 10 110 0110 10110

Binary Subtraction

Uses the same principle of "borrowing" that decimal subtraction uses.

0 1

0 0 1 (with a borrow from the next column)

1 1 0

Binary Subtraction Table Example

borrow 01 01 01 0 0

Minuend 10100 10100 10100 10100 10100 10100

Subtrahend - 1001 - 1001 - 1001 - 1001 - 1001 - 1001 Difference 1 11 011 1011 01011

Note: This problem in decimal is 20 – 9 = 11 which is the answer we get in binary.

Character set encoding systems

A character is a digit, an alphabet or a symbol that can be stored and manipulated by a computer. They 0,1,2...9, A,B,C,...Z, a,b,c, .... Z, ,.:;'"[]{}|\, etc. The American Standard Code for Information Interchange and the Extended Binary Coded Decimal Interchange Code are two character encoding schemes; which are more commonly known by their respective acronyms, ASCII and EBCDIC. The main difference between the two is the number of bits that they use to represent each character. EBCDIC uses 8 bits per

character while the original ASCII standard only used 7, due to concerns that using 8 bits for characters that can be represented with 7 is much less efficient.

The main consequence of that difference is the number of characters that can be

(10)

accommodated with each one. EBCDIC can accommodate up to 28 characters for a total of 256 while the 27 of ASCII has a maximum of 128 characters.

Although EBCDIC was very popular, due largely to the popularity of IBM machines at the time, it had several problems that irritated programmers. The first one is how it arranges the letters of the alphabet. In ASCII, all the letters are in consecutive order. Capital letters are grouped together while small letters also have their own group. In EBCDIC, the letters are grouped 9 at a time. This non-intuitive layout comes from the EBCDIC’s punch card origins and is quite difficult for programmers to deal with.

IBM’s hold of the EBCDIC coding has led to many problems when it comes to updates.

ASCII and EBCDIC later had updates to increase the number of characters that they can accommodate. ASCII pages had some code points replaced while maintaining most of the other code points. With EBCDIC, the different versions are highly incompatible with each other.

As the encoding needs of computer outgrew both ASCII and EBCDIC, other standard emerged. The most recent is Unicode, which incorporated ASCII. The first 128 characters of Unicode are from ASCII. This lets Unicode open ASCII files without any problems. On the other hand, the EBCDIC encoding is not compatible with Unicode and EBCDIC encoded files would only appear as gibberish.

Summary:

Therefore, EBCDIC uses 8 bits while ASCII uses 7 bits.

5.1. Ms Word Advanced

A word processor is an application whose principal function is the preparation of documents, reports and letters. Microsoft Word is an example of a word processing package. Other variations include Open Office and Word Perfect.

Mail Merge

Mail merge is a function in word that lets the user prepare one document and then send to many recipients whose details are stored in a database (or a data file).

To start the mail merge wizard select Tools > Letters and mailings > Mail merge wizard, and follow the wizard to create a form letter (or use an existing one) and then create a data file (or use an existing one), then insert the merge fields into the form letter, and when done preview the merged letters or click finish to complete the merging. On completing the merging the user ends up with three files; the form letter which contains the standard letter that contains common information for all the recipients, then the data file that contains the database of the contacts and other variable information. The merged file on the other hand shall contain all the letters created from a single form letter and the data file addresses.

This is a very important tool in automating office letters and other documents such as

reports.

(11)

5.2. Ms Excel Advanced

Microsoft Excel is a spreadsheet software. A spreadsheet is a software that is used for tabulating data such as financial reports, statistical analysis and mathematical data. It is a powerful tool for decision modeling such as product costing, break-even analysis, goal seeking, etc.

In a business environment a number of financial applications are important, and can easily done using Ms Excel. They include cash-flow analysis, pricing catalogue, receipts,

invoices, profit and loss accounts, balance sheets, etc.

Exercise:

Assume you are setting up a small business that shall be issuing quotations, invoices, and receipts. Design a template of these documents and a cash-flow projection for your first year of business.

Tips

Learn how to use formula and functions, auto-fill, re-calculate, etc

5.3. Introduction to Ms Access

Ms Access is a database management system (DBMS). A database is a collection of related records such as students marks register, inventory, bank account holders, etc. A record is a collection of related fields and usually is represented by a row in case of relational database. A field on the other hand is a characteristic of an object or an entity that is been stored in the database. For example in the student's marks register database, each individual student will be a record. Then characteristics of a student such as Name, DateofBirth, CourseCode shall be fields.

5.3.1. Access Database Objects

Tables contain rows called records and columns called fields.

Queries are requests for specific information from a database.

Forms are parts of user interface. Forms are used to enter, edit or browse data from a database

Reports present requested information and allow to create hard copies.

5.3.2. Data Types Text

Memo Numbers Byte Integer

Long integer

Single

Double

Date/time

(12)

Currency AutoNumber Yes/No among others

5.3.3. Create a Database in MS Access 2007 Click on the round Office button

Choose New from the drop-down menu

In Create Blank Database window specify the database name Click Create

5.3.4. Access Forms Create using Form Wizard Create using Form Design view

Specify source of data will be presented by the form Table

Query

Specify fields related to the form Add labels, titles, graphics and so on In the Form Design View

Form Header –a place for titles, graphics, additional information

Form Details section – the fields used to create a form and control elements related to the fields

Form footer –a place for any items which will appear at the bottom of the form

To view a Form Open database

Click Forms tab to display all available forms in the database Select the form

Select Open

To view data use Form Navigation Tools. To prevent data Editing, use Locked Property for the Text Boxes

5.3.5. Create Table Using Wizard Design View

Specify field names Data types

Properties

Determine a primary key Save the table

Design view

Table structure is created and may be edited

Datasheet view

(13)

Display table content in spreadsheet-like grid,

Used for entering, editing or deleting data from tables

5.3.6. Queries

Specify the source of data

If multiple tables are used, specify relationships between tables

Select desirable fields from the table(s) and options related to the fields Specify a criterion

To be selected a record must satisfy a criterion Expressions may contain the following operators:

Math Operators (+,-,/,*)

Relational operators (=,>,<,<=,>=,<>) Boolean Operators (AND, OR, NOR, XOR)

String Operators and Miscellaneous Operators (&,Like, In, Is Null, Between .. And..)

5.3.7. Reports

Reports present table contents or query results in an easily assimilated format Reports have Design view and Print Preview

Report Design View is similar to the Form Design view With a Wizard

Design view:

Specify source for the report Select Fields from the Fields List Add labels

Add format

Switch the view to see the result.

Understanding Report Design View

Page Header contains data and graphics appearing at the top of each page

Report Header contains the data and graphics appearing at the top of the first report page Detailed section contains data from tables or queries

Page Footer contains the data and graphics appearing at the bottom of every page Report Footer contains the data and graphics appearing at the bottom of the last report page

6. 4. Week7-8: Introduction to computer programming concepts and tools

6.1. Definition of Key terminologies

A Program: Is a set of instructions a computer follows in order to perform a task

A Programming Language: Is a special, high level language used to write computer

(14)

programs

Computers can only follow instructions

A computer program is a set of instructions on how to solve a problem or perform a task In order for a computer to compute someone’s gross pay, we must tell it the steps to perform. When the steps are stated in our human language we call them algorithms.

However, the common practice is to abbreviate these steps in our own colloquial vocabulary. This abbreviated colloquial vocabulary in for the algorithm is called pseudocode.

For example an algorithm for the computation of Net pay above might be as follows Start

Enter the basic pay, allowance, deductions Let NetPay=Basic pay + allowance -deductions Display NetPay

Stop

6.2. Flow charting, algorithms and pseudocodes

Algorithms and pseudocodes cannot execute in a computer but they provide a means of visualizing what the programming is doing and helps the programmer design his or her code.

Together with the pseudocode the programmer shall design a flow chart to represent the a diagrammatical view of the flow of program logic.

Example

a) What is a flow chart? Draw a flow chart for obtaining NET PAY for 10 employees who earn a BASIC PAY and HOUSE ALLOWANCE. The employees’ pay PAYE and some take ADVANCE pay. Write some algorithm for the flowchart. (10 marks)

A Flowchart is a diagrammatic tool for modeling the flow of logic in program design. It

shows the input, processes, decisions and output of the program and thus acts as visual

aid to program development

(15)

Algorithm Start

‘connector number 1 is placed here

INPUT BasicPay, Allowance, Advance, PAYE

LET NetPay = BasicPay + Allowance – Advance – PAYE

OUTPUT NetPay

(16)

LET Count=Count + 1 IF Count=10 THEN Stop ELSE GOTO 1

STOP

6.3. Introduction to computer programming languages

Since a computer cannot understand our normal language, its programs are written in a coding language that is understandable to it. This language is called a computer language.

There are two levels of programming languages, namely;

- Low Level Programming Language - High Level Programming Language

Low Level Programming Langauges

Low level programming language is a language for coding programs that is close to the hardware design or circuitry of the computer. It includes two types of computer languages - machine language and assembly language. This code is easier for the computer to execute but laborious for the programmer. Machine language is the lowest type of programming language where all the coding is in binary digits 0,1 such that it directly executes on the computer without any translation. However, although such coding executes very fast, coding on this language can be extremely laborious to the programmer and such programs are machine dependent and so one program cannot be used on another different machine. This coding is therefore used only in hardware abstraction layer programming such as microprocessor programming by computer scientists.

Assembly language on the other hand is a programming language that uses abbreviations called mnemonics for its commands and instructions. For example, MULT, ADD, DIV, SUB, etc. It is easier to use than machine language but still laborious for the programmer. Although it needs translation to machine language by a tool called an assembler, it is still faster to execute that the high level language codes. Therefore, it is also used in programming the hardware abstraction layer of the computer but not for business programming.

High Level Programming Languages

High level language refers to programming language that is closer to normal

English language and therefore easier for the programmer to code but requires

(17)

to be converted into computer sensible format. It includes Fourth Generation Languages (4GLs) and Artificial Intelligence, e.g. C++, Visual Basic, FoxPro etc.

Other terminologies used with programming languages Object code versus source code

Object code is the code that is generated when a High Level Language or Assembly Language is converted into Machine Language by a Compiler.

Source code is the original program code as coded by the programmer before compiler converts it to object code.

Compiler versus Interpreter

Compiler is a programming tool that converts a high level language source code to a machine code equivalent at once to generate a new object code, e.g. Visual Basic has a compiler tool integrated into it.

An interpreter is a programming tool that converts a high level language code to machine code a statement at a time, normally it does not generate a new object code.

7. Week 9-13: Visual Basic Programming for Business Application Development

7.1. Introduction to VB environment and features

Visual Basic is 4GL programming language that is also Object Oriented Programming Language, and Structured Programming Language. It uses a Graphical User Interface (GUI) for its user interaction and provides an Integrated Development Environment (IDE).

- Object Oriented Programming places the code and data in a single location called an object.

- Structured programming is a logical structure of a program that makes writing code more

efficient and simpler to modify. Structured programming is easier to fix/ modify as well as

work faster when trying to solve a problem. An advantage of using structured design is the

(18)

capability to reduce the use of the GOTO statement. (Although some structured program languages do support the GOTO statement.)

- Graphical User Interface (GUI) is a programming environment that enables the programmer to interact with visual objects rather than memorizing keystrokes for commands. It therefore provides a user friendly programming environment.

Visual Studio is an integrated development environment, often abbreviated as IDE

• Provides everything needed to create, test, and debug software including:

• The Visual Basic language

• Form design tools to create the user interface

• Debugging tools to help find and correct programming errors

• Visual Studio supports other languages beside Visual Basic such as C++ and C#

7.2. Form design and Windows Application Forms in VB

Now a short step-by-step explanation of how to create and run this program using the features of Visual Studio:

Create the console application

Start Visual Studio from the Start menu of your computer Select File > New > Project…

In the left pane, select Visual Basic Projects In the right pane, select Console Application Name the project Welcome1

Specify the desired location

Change the name of the program file

Click Module1.vb in the Solution Explorer window

In the Properties window, change the File Name property to Welcome1.vb

7.3. Coding VB procedures 7.4. Testing and Debugging

8. Idea

References

Related documents