Download presentation
1
Introductory Computer Sciences
YILDIZ TECHNICAL UNIVERSITY Introductory Computer Sciences ASST. PROF. DR. cenk budayan
2
ve YARBİS Office Hours: Monday 14:00 – 16:00 Wednesday 15:00-17:00 Office: 1-064
3
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)
4
High Level Programming Languages
Description Visual Basic, C# Popular programming languages for building windows and web applications. Use a graphical user interface C, C++ Powerful advanced programming languages that emphasize flexibility and fast running times. C++ is also object oriented. Java Flexible and powerful programming language that runs on many different computer systems. Often used to teach object-oriented programming Python Simple, yet powerful programming language used for graphics and small applications PHP Programming language used for creating interactive Web sites JavaScript Scripting language used in Web applications that provides rich used interfaces for Web Browsers.
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 classes Classes contain attributes, expressed as variables. For example, student class can have attributes such as Student 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 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.
8
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.
9
Installation of Visual Basic
10
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.
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.
12
Procedure Input Process Output
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 product Price* 0,18 Tax
16
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.)
17
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.
18
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.
19
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
20
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
21
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.
22
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.
23
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.
24
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.
25
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.
26
Flowchart Symbol Name Meaning 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. Connector Used to join different flowlines Annotation Used to provide additional information about another flowchart symbol
27
Flowchart
28
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.
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) 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.
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 Chart Postage stamp program Read sheets Calculate stamps Set stamps= sheets / 5 Round stamps up to next whole number Display stamps
32
Decision Structure
33
Repetition Structure
34
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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.