1 Turgay Korkmaz Office: NPB 3.330 Phone: (210) 458-7346 Fax: (210) 458-4437 web:

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 1 Engineering Problem Solving.
Advertisements

Computer Programming w/Eng. Applications
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
CSCI 1412 Tutorial 1 Introduction to Hardware, Software Parminder Kang Home:
ICS103 P ROGRAMMING IN C L ECTURE 1: O VERVIEW OF C OMPUTERS & P ROGRAMMING.
COSC 120 Computer Programming
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
Ch. 1 Engineering Problem Solving. Contents I.Engineering in the Twenty-First Century II.Computing Systems: Hardware and Software III.An Engineering Problem-Solving.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
CS 201 Overview of Computers & Programming Debzani Deb.
CMPT 120 Introduction to Computer Science and Programming I Chris Schmidt.
1 Introduction to computers Overview l · Grading Policy »Cheating Rules (serious concern) »Examinations and Fixation of Timings »Quizzes »Homework Assignments.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
1 CHAPTER 4 LANGUAGE/SOFTWARE Hardware Hardware is the machine itself and its various individual equipment. It includes all mechanical, electronic.
Systems Software Operating Systems.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Introduction COMP104: Fundamentals and Methodology.
CMPT 300: Operating Systems
INTRODUCTION TO COMPUTER PROGRAMMING itc-314 LECTURE 01.
Chapter 1 Engineering Problem Solving 1. Hardware and Software 2 A computer is a machine designed to perform operations specified with a set of instructions.
CS 0004 –Lecture 1 Wednesday, Jan 5 th, 2011 Roxana Gheorghiu.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions.
EG280 Computer Science for Engineers Fundamental Concepts Chapter 1.
School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic.
COMPUTER PROGRAMMING. Computer programming the objective of the module to gain the necessary skills to develop a computer program using one of the high.
12/4/20151 Introduction To Computer Science Bina Ramamurthy.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Computing Systems & Programming ECE Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Software. 2 What is software ► Software is the term that we use for all the programs and data on a computer system. ► Two types of software ► Program.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Introduction ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
Chapter 1 An Overview of Computers and Programming Languages.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Introduction to Computer Programming By: Mr. Baha Hanene Chapter 1.
CHAPTER 1 OVERVIEW OF COMPUTER AND PROGRAMMING 1.1 Electronic Computer Then and Now 1.2 Computer Hardware 1.3 Computer Software 1.4 The Software Development.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT Operating Systems.
Chapter 3 Getting Started. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To give an overview of the structure of a contemporary.
Chapter 1: Introduction to Computers and Programming
Chapter 1 Introduction 2nd Semester H
Java Programming: From the Ground Up
BASIC PROGRAMMING C SCP1103 (02)
Engineering Problem Solving With C An Object Based Approach
Key Ideas from day 1 slides
Chapter 1: An Overview of Computers and Programming Languages
BASIC PROGRAMMING C SCP1103 (02)
DDC 1023 – Programming Technique
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
C++ Programming: From Problem Analysis to Program Design
Introduction CSC 111.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
National Diploma in Computer Studies
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
ICS103 Programming in C 1: Overview of Computers And Programming
Presentation transcript:

1 Turgay Korkmaz Office: NPB Phone: (210) Fax: (210) web: CS 1063 Introduction to Computer Programming I Ch 0 – Overview - Problem solving

2 What is the goal of a programmer? Solve problems using computing systems

3 Problem Solving Main part of problem solving is to figure out Algorithms (necessary steps/instructions and their orders) and Appropriate data structures Then to code the algorithm and the data structure in some programming language (we will use Java) Computers cannot think or develop a solution! You do! Computers just follow your instructions and do the operations faster Then how do computers do many things? Even play a game, for example chess! For the same problem, we may come up with different and yet correct solutions. Efficiency vs. Cost

Computing System Computer: a machine that is designed to perform operations (set of instructions called program) to achieve a specific task (e.g., 3+4) Hardware: computer equipment (e.g., computer, keyboard, mouse, terminal, hard disk, printer) Software: programs that describe the steps we want the computer to perform. 4

5 Computer Hardware CPU - Central processing unit ALU - Arithmetic and logic unit ROM - Read only memory RAM - Random access memory CPU Internal Memory External Memory InputOutput Processor ALU In this sense, do you think we are like a computer? + we have intelligence

6 Computer Software Operating System - Provides an interface with the user unix, windows, linux,... Software Tools word processors (MicrosoftWord, WordPerfect,...) spreadsheet programs (Excel, Lotus1-2-3,...) mathematical computation tools (MATLAB, Mathematica,...) Computer Languages machine language assembly language binary language high level languages (C, C++, Ada, Fortran, Basic, java) WE WILL STUDY Java PROGRAMMING LANGUAGE abstractions

What is Java? General purpose, machine-independent, high- level programming language Developed by Sun Microsystems in 1995, now part of Oracle 7 Source file Compiler javac Executor/Interpreter java Machine-code Output… Screen File Printer etc.

Hello World! Type your program … and save it Compile and run it trough Dr. Java or Compile and execute your program elk03 :> javac HelloWorld.java elk03 :> java HelloWorld 8

9 PROBLEM SOLVING  Very Important  If you can develop solution, then coding in Java is easy…  So, before studying Java, let us see a few examples of problem solving

Problem Solving Methodology 1. State the problem clearly 2. Describe the input/output information 3. Work the problem by hand, give example 4. Develop a solution (Algorithm Development) and Convert it to a program (Java program) 5. Test the solution with a variety of data 10

11 Example 1 1. Problem statement Compute the distance between two points 2. Input/output description Point 1 (x1, y1) Point 2 (x2, y2) Distance between two points (distance) (x1,y1) (x2, y2) straight line in a plane

12 3. Hand example Example 1(cont’d) side1 = = 3 side2 = = 2

13 Example 1(cont’d) 4. Algorithm development and coding a. Generalize the hand solution and list/outline the necessary operations step-by-step 1) Give specific values for point1 (x1, y1) and point2 (x2, y2) 2) Compute side1=x2-x1 and side2=y2-y1 3) Compute 4) Print distance b. Convert the above outlined solution to a program using any language you want (see next slide for imp in C and Java)

14 Example 1(cont’d) C program Java program

15 Example 1(cont’d) 5. Testing After compiling your program, run it and see if it gives the correct result. Your program should print out The distance between two points is 3.61 If not, what will you do?

16 Modification to Example 1 x1=2, y1=5; x2=10, y2=8; How will you find the distance between two other points (2,5) and (10,8)?

17 Simple examples to develop solutions

18 Compute the area of a triangle 1. State problem 2. I/O 3. Hand example 4. Develop solution and Coding 5. Testing area xyxy x=3 cm y=4 cm area = ½ * 3 *4 = 6 cm 2 1.Get values of x and y 2.Compute area = ½*x*y 3.Print area

19 Given the number of seconds, find number of hours, minutes and seconds 1. State problem 2. I/O 3. Hand example 4. Develop solution and Coding 5. Testing 3675 seconds can be written as 1 hour 1 min 15 sec H total_sec M S 1.Get total_sec 2.H = total_sec / 3600 (integer division) 3.M = (total_sec – (H*3600)) / 60 M = (total_sec mod 3600) / 60 4.S = total_sec – (H*3600) – (M*60) 5.Print H hour, M min, S sec

20 A little bit difficult examples to develop solutions Some problems are from How to Solve it: Modern Heuristics by Michalewicz and Fogel. Springer 2004.

21 Average speed Suppose a car goes from city A to city B with speed of 40 mph and immediately comes back with the speed of 60 mph. What is the average speed? Can you generalize this solution and outline step by step to find average speed when the speed from A to B is X and the speed from B to A is Y? Income, grade, speed

22 Dimensions of a rectangle ranch? A farmer has a rectangular ranch with a perimeter of P=110 meters and an area of A=200 square meters. What are the dimensions of his ranch? What are the dimensions for any P and A? x y

23 Climbing a wooden post A snail is climbing a wooden post that is H=10 meters high. During the day, it climbs U=5 meters up. During the night, it falls asleep and slides down D=4 meters. How many days will it take the snail to climb the top of the post? Given that H > U > D. Can you generalize your solution for any H, U, and D?

Minimum number of coins Suppose you want to give x=67 cents to a person, what is the minimum number of coins You have many 25, 10, 5, 1 cents 24

25 Assign letter grades Suppose I have your grades as follows name final midterm avg_hw quizze letter aaaa ? bbbb ? … How can I assign letter grades?

26 Example: Sum of numbers Given n (for example n=1000), compute sum = …+n sum_odd = …+(2n+1) ln2=1- 1/2 + 1/3 - 1/4 +…  1/n

27 Ten heuristics for problem solving How to Solve it: Modern Heuristics by Michalewicz and Fogel. Springer Don’t rush to give an answer, think about it 2. Concentrate on the essentials and don’t worry about the noise (tiny details) 3. Sometimes finding a solution can be really easy (common sense), don’t make it harder on yourself 4. Beware of obvious solutions. They might be wrong 5. Don’t be misled by previous experience

28 Ten heuristics for problem solving How to Solve it: Modern Heuristics by Michalewicz and Fogel. Springer Start solving. Don’t say “I don’t know how” Most people don’t plan to fail, they just fail to plan! 7.Don’t limit yourself to the search space that is defined by the problem. Expand your horizon 8.Constraints can be helpful to focus on the problem at the hand 9.Don’t be satisfied with finding a solution, look for better ones 10.Be patient. Be persistent!