How we communicate with the computer Machine Language (Lowest Level) Symbolic Language Low Level Programming Languages: It is close to the machine language. It converts to the machine language by using a small program, therefore it is faster than the high level programming languages (assembly). High Level Programming Languages: It consists of instructions to which people can relate, such as Click, If, and Do. (Visual Basic, C, C++, Java)
Object oriented programming Is an industry standard model for designing and coding programs. When designing applications, designers use real-world objects to express patterns, called classes in software. For example, a student registration application: Students and transcripts as possible classes Classes contain attributes, expressed as variables. For example, student class can have attributes such as Student ID, name, surname
Graphical User Interface (GUI) User Friendly. Simplified interaction with the computer. Not simplified the task of programming. Require on-screen elements such as windows, dialog boxes, buttons and menus. Uses mouse for interaction. No longer does the user respond to a program – now the program responds to a user.
Visual Basic Visual Basic (VB) is one of the programming environment which can be used for performing many purposes easily. In the early 1960s, two mathematics professors at Dartmouth College developed a programming language called BASIC to provide their students with an easily learned language that could tackle complicated programming projects. As the popularity of BASIC grew, refinements were introduced that permitted structured programming, which increased the reliability of programs. Visual Basic 1.0 is a graphical version of BASIC developed in 1991 by the Microsoft Corporation to allow easy, visual-oriented development of Windows applications.
Visual Basic VB is not only limited with programming, but also it can be used for developing programs in MS Office (Excel, Word, Powerpoint and Outlook Express) via Visual Basic Application(VBA). VBScript used for developing Web applications is one of the subsets of VB. VB can be used for programming for many different objects. It varies for a small program to a web application which can be used by the entire world. As you can understand, VB is a simple however a powerful language.
Installation of Visual Basic
Programming Programming: creating a sequence of instructions to enable the computer to do something. Program: is a set of instructions a computer follows in order to perform a specific task. A program can consist of one or two command lines or can consist of million command lines. For example; Windows operating system is written with millions of command lines, on the other a tax program can be formed of two command lines.
Program Computers are designed to follow instructions. These instructions are called an algorithm. An algorithm is a set of well-defined steps for performing a task or solving a problem. These steps should be sequentially ordered. The computers can only follow the instructions and they do not evaluate these instructions and examine whether these instructions are logic or not.
Performing a task on the computer 1. The first step in writing instructions to carry out a task is to determine what the output should be — that is, exactly what the task should produce. 2. The second step is to identify the data, or input, necessary to obtain the output. 3. The last step is to determine how to process the input to obtain the desired output – that is, to determine what formulas or ways of doing things should be used to obtain the output.
Example How fast is a car moving if it travels 50 miles in 2 hours The type of the answer requested. (speed) The information needed to obtain the answer. (distance and time) The procedure required to obtain the answer by using the available information. (distance / time)
Example Finding the tax for a product. (tax: 18% of the price of the product) Tax Price of the product Price* 0,18
Program planning Software Development Cycle Analyze: Define the problem Design: Plan the solution to the problem. Design the interface: Select objects (text boxes, buttons etc.)
Program planning Code: Translate the algorithm into a programming language. Test and correct: Locate and remove any errors in the program. Complete the documentation: Organize all the material that describes the program.
Example Calculate the gas mileage which is the number of miles traveled divided by the number of gallons of gas used. Therefore, your program needs to compute the number of miles traveled since the last fill-up, and the number of gallons used during this period. Let’s suppose that you always fill up the gas tank. Therefore, the amount of gas that you put in the car is the amount used since the last fill-up.
Example To compute the number of miles you need to subtract the odometer reading at the last time you filled up the tank from the odometer reading at this filling time. This means that you need to have saved the odometer reading from the last time you filled up. Suppose you have done so by writing the odometer reading and storing it in your glove compartment. Therefore, the inputs to your procedure are: The current odometer reading The amount of gas pumped
First Solution 1. Read odometer value. 2. Subtract previous odometer value from the current odometer value to obtain the number of miles traveled. 3. Divide by the number of gallons of gas pumped to determine the mileage
Second Solution 1. Read the current odometer value. 2. Write the odometer value obtained in step 1 on a piece of paper 3. Retrieve the previous value from the glove compartment. 4. Store the paper from step 2 in the glove compartment. 5. Subtract the value obtained in step 3 from the value obtained in step Fill the tank. 7. Read the number of gallons pumped. 8. Divide the number obtained in step 5 by the number obtained in step Display the number obtained in step 8 as the mileage. 10. Stop.
Third Solution 1. Read the current odometer value. 2. Write the odometer value obtained in step 1 on a piece of paper. 3. Is this the first time for this procedure? (a) If the answer is yes, (i) Store the paper from step 2 in the glove compartment. (ii) Stop. (b) If the answer is no, retrieve the previous value from the glove compartment. 4. Store the paper from step 2 in the glove compartment. 5. Subtract the value obtained in step 3(b) from the value obtained in step Fill up the tank. 7. Read the number of gallons pumped. 8. Divide the number obtained in step 5 by the number obtained in step Display the number obtained in step 8 as the mileage. 10. Stop.
Fourth Solution 1. Read the current odometer value. 2. Write the odometer value obtained in step 1 on a piece of paper. 3. Is there a previous odometer reading in the glove compartment? (a) If the answer is no, (i) Store the paper from step 2 in the glove compartment. (ii) Stop. (b) If the answer is yes, retrieve the previous value from the glove compartment. 4. Store the paper from step 2 in the glove compartment. 5. Subtract the value obtained in step 3(b) from the value obtained in step Fill up the tank. 7. Read the number of gallons pumped. 8. Divide the number obtained in step 5 by the number obtained in step Display the number obtained in step 8 as the mileage. 10. Stop.
Programming tools Pseudocode: Uses English-like phrases with some Visual Basic terms to outline the task. Flowcharts: Graphically depict the logical steps to carry out a task and show how the steps relate to each other. Hierarchy charts: Show how the different parts of a program relate to each other.
Programming tools You decide to mail a letter, however you must decide how much postage to put on the envelope. One rule of thumb is to use one stamp for every five sheets of paper. Suppose a friend asks you to determine the number of stamps to place on an envelope.
Flowchart SymbolNameMeaning Flowline Used to connect symbols and indicate the flow of logic Terminal Used to represent the beginning or the end of a task Input/Output Used for input and output operations, such as reading and displaying. The data to be read or displayed are described inside. Process Used for arithmetic and data manipulation operations. The instructions are listed inside the symbol. Decision Used for any logic or comparison operations. Unlike the other symbols, the decision symbol has one entry and two exits. ConnectorUsed to join different flowlines Annotation Used to provide additional information about another flowchart symbol
Pseudocode Pseudocode is an abbreviated plain English version of actual computer code The geometric symbols used in flowcharts are replaced by English-like statements that outline the process. As a result, pseudocode looks more like computer code than does a flowchart. Pseudocode allows the programmer to focus on the steps required to solve a problem rather than on how to use the computer language. The programmer can describe the algorithm in Visual Basic- like form without being restricted by the rules of Visual Basic.
Pseudocode Read sheets number (input) Set the number of stamps to Sheets (sheets/5) (process) Round the number of stamps up to the next whole number (process) Display the number of stamps(output) Advantages It is compact and probably will not extend for many pages as flowcharts commonly do. Also, the plan looks like the code to be written and so is preferred by many programmers.
Hierarchy Chart shows the overall program structure. depict the organization of a program but omit the specific processing logic. describe what each part, or module, of the program does and they show how the modules relate to each other. The details on how the modules work, however, are omitted. The chart is read from top to bottom and from left to right. Each module may be subdivided into a succession of submodules that branch out under it. The main benefit of hierarchy charts is in the initial planning of a program. We break down the major parts of a program so we can see what must be done in general. From this point, we can then refine each module into more detailed plans using flowcharts or pseudocode. This process is called the divide-and-conquer method.
Hierarchical Chart Postage stamp program Read sheets Calculate stamps Set stamps= sheets / 5 Round stamps up to next whole number Display stamps
Homework Calculate and report the average grade for a class. Output: Average grades Input: Student grades Process: Find the sum of the grades, count the number of students, calculate the average grade = sum of grades / number of students Draw the flowchart of this program.