3 How we communicate with the computer Machine Language (Lowest Level)Symbolic LanguageLow 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)
5 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 classesClasses contain attributes, expressed as variables.For example, student class can have attributes such asStudent ID, name, surname
6 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.
7 Visual BasicVisual 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.
8 Visual BasicVB 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.
10 ProgrammingProgramming: 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.
11 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.
13 Performing a task on the computer 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.The second step is to identify the data, or input, necessary to obtain the output.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.
14 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)
15 Example Price* 0,18 Price of the product Tax Finding the tax for a product. (tax: 18% of the price of the product)Price of the productPrice* 0,18Tax
16 Program planning Software Development Cycle Analyze: Define the problemDesign: Plan the solution to the problem.Design the interface: Select objects (text boxes, buttons etc.)
17 Program planningCode: 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.
18 ExampleCalculate 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.
19 ExampleTo 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 readingThe amount of gas pumped
20 First Solution1. 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
21 Second Solution1. 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.
22 Third Solution1. 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.
23 Fourth Solution1. 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.
24 Programming toolsPseudocode: 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.
25 Programming toolsYou 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.
26 Flowchart Symbol Name Meaning Flowline Used to connect symbols and indicate the flow of logicTerminalUsed to represent the beginning or the end of a taskInput/OutputUsed for input and output operations, such as reading and displaying. The data to be read or displayed are described inside.ProcessUsed for arithmetic and data manipulation operations. The instructions are listed inside the symbol.DecisionUsed for any logic or comparison operations. Unlike the other symbols, the decision symbol has one entry and two exits.ConnectorUsed to join different flowlinesAnnotationUsed to provide additional information about another flowchart symbol
28 PseudocodePseudocode is an abbreviated plain English version of actual computer codeThe 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.
29 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)AdvantagesIt 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.
30 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.
31 Round stamps up to next whole number Hierarchical ChartPostage stamp programRead sheetsCalculate stampsSet stamps= sheets / 5Round stamps up to next whole numberDisplay stamps
34 Homework Calculate and report the average grade for a class. Output: Average gradesInput: Student gradesProcess: Find the sum of the grades, count the number of students, calculate the average grade = sum of grades / number of studentsDraw the flowchart of this program.