Computer Programming Mr. José A. Ortiz Morris. Computer Language  Languages that the computer understands.  They are low level languages. (BINARY 1.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Programming Methodology (1). public class Hello { public static void main(String[] args) { System.out.println("Hello world"); } } Hello world.
Computing Science Software Design and Development SOFTWARE DESIGN AND DEVELOPMENT USING PYTHON.
PSEUDOCODE & FLOW CHART
Programming TBE 540 Farah Fisher. Objectives After viewing this presentation, the learner will be able to… Given a task, create pseudocode Given pseudocode,
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
COSC 120 Computer Programming
COMP 4—Power Tools for the Mind1 PowerTools What’s in the Box? Turing 1: An Introduction to Programming You will learn elementary computer programming.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
CIS105 Chapter 1 Theory Review. Page 2 Hardware and Software are the two major components o any computer system Hardware is the set of physical devices.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
Chapter 2: Input, Processing, and Output
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
CS 1400 Chapter 1 Introduction and Background
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 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Introduction to computer: storing instructions and information.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
CIS Computer Programming Logic
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
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.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Input, Output, and Processing
Agenda Exam #1 Review Modulus Conditionals Boolean Algebra Reading: Chapter Homework #5.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Fundamental Programming: Fundamental Programming Introduction to C++
An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic.
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Programming, an introduction to Pascal
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
CHAPTER 2 PART #3 C++ INPUT / OUTPUT 1 st Semester King Saud University College of Applied studies and Community Service CSC1101 By: Fatimah.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
GCSE Computing: Programming GCSE Programming Remembering Python.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Chapter 1: Introduction to Computers and Programming
Unit 2 Technology Systems
Development Environment
CST 1101 Problem Solving Using Computers
Input and Output Upsorn Praphamontripong CS 1110
Building Java Programs
Programming Mehdi Bukhari.
Chapter 1. Introduction to Computers and Programming
Variables, Expressions, and IO
Building Java Programs Chapter 2
Building Java Programs
Building Java Programs Chapter 2
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Understand the interaction between computer hardware and software
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs Chapter 2
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
Building Java Programs
Hardware is… Software is…
Presentation transcript:

Computer Programming Mr. José A. Ortiz Morris

Computer Language  Languages that the computer understands.  They are low level languages. (BINARY 1 / 0)  People used to program computers using them.

Low level languages  Language that only the computer’s CPU and other processing components can understand.  They are very difficult to understand by human beings.  Ex  Programmers used to program in this type of language.

High level language  Language that is similar to regular human languages.  A CPU can’t understand it and it is used by programmers to program software.  Ex. System.out.println(“Hello World!”);  This type of language is sent to a compiler so that it can be turned to a low level language so that the computer can understand it.

Starting to Program  When we start to program the first thing that we have to understand is that the computer needs specific instructions to be able to perform the specific tasks it has to do.  Computers are not intelligent. They just do whatever the programmer tells it to do.

Giving instructions to the computer…  When a programmer gives instructions to the computer he/she used a high-level programming language to give them and its written down in a source code (Group of instructions that form a computer program).  The different instructions activate different components of the computer.

Using different tools to help with programming…  Since understanding a high-level computer language is difficult at first, pseudocodes and flowcharts to help understand the process the program has to do before writing down the source code.

Flowcharts Start End Display = “Hello!” Display = “Goodbye!”

Pseudocode Start Display = “Hello!”; Display = “Goodbye!”; End

Understanding each instruction…  In the previous examples of flowcharts and pseudocode we can see only 1 type of instruction. The Display instruction is used to send information to a monitor or any other type of output device to present it.  Start and End are just there to know that the program’s source code starts and ends at those specific points.

Other types of instructions…  Get = this instruction is used to acquire information from an input device. In this class we will always assume is from a keyboard.  Ex. Get = name;

Explaining the basic form of instructions…  In the last example we had an instruction: Get = name;  This instruction has 4 components:  The function ( Get )  An assigning operator ( = )  A variable ( name )  And an end mark ( ; )

Example… Start Display = “Please enter your name”; Get = name; Display = name; End

Variable Data Types  For the remainder of this topic we are going to use different types of variables and each type of variable has different data types:  String = stores text.  Ex. “Anthony”  Integer = stores whole numbers.  Ex. 25  Real = stores real numbers.  Ex  Boolean = stores true or false (used for logical comparisons)  Ex. true

To use variables…  When you are going to use a variable in a computer program code you have to define them so that the computer will know what type of value they will store and to reserve the space in memory.  The format in this class to define a variable is: DEF name : string;

Reviewing previous code…  The last code that we wrote had an error. We didn’t define the variable to be able to use it. The correct way to write it would be the following: Start DEF name : string; Display = “Please enter your name”; Get = name; Display = name; End

Exercise… Write a program that: 1. Asks the user his name 2. Asks the user his age. 3. Asks the user 2 grades. 4. Calculates the average of the 2 grades. 5. Displays the result as the following: Hello, John Doe You are 12 years old Your grade average is 75.3

Start DEF name : string; DEF age : integer; DEF grade1, grade2, average : real; Display = “Please enter your name: ”; Get = name; Display = “Please enter your age: ”; Get = age; Display = “Please enter your first grade: ”; Get = grade1; Display = “Please enter your second grade: ”; Get = grade2; average = (grade1 + grade2)/2; Display = “Hello, ” + name; Display = “Your age is ” + age; Display = “Your grade average is ” + average; End

Exercise 2… Write a program that: 1. Asks the user his name 2. Asks the user his last name 3. Asks the user his age. 4. Asks the user 3 grades. 5. Asks the user his phone number. 6. Calculates the average of the 3 grades. 7. Displays the result as the following: Hello, John Doe You are 12 years old Phone#: Your grade average is 75.3

Start DEF name, lname : string; DEF age, phone : integer; DEF grade1, grade2, grade3, average : real; Display = “Please enter your name: ”; Get = name; Display = “Please enter your last name: ”; Get = lname; Display = “Please enter your age: ”; Get = age; Display = “Please enter your phone #: ”; Get = phone; Display = “Please enter the 1st grade: ”; Get = grade1; Display = “Please enter the 2nd grade: ”; Get = grade2; Display = “Please enter the 3rd grade: ”; Get = grade3; average = (grade1 + grade2 + grade3)/3; Display = “Hello, ” + name + “ ” + lname; Display = “You are ” + age “ years old.” Display = “Phone#: ” + phone Display = “Your grade average is ” + average; End

The If Statement function…  Programs have a need to be dynamic to be able to perform different functions for the user.  The if statement helps the programmer create something that can do 1 of 2 or more things.

If statement example…  If you have a program that has already asked the user his name, his last name and his marital status (single or married) and gender(Male or Female). You can show the different marriage status title before the name (Mr., Ms., or Mrs.)  Here is how it would be coded: If gender = “Male” Display= “Hello, Mr. ” + name + “ ” + lname Else Display= “Hello, Mrs. ” + name + “ ” + lname;

Example with Marital Status… Start. If gender = “Male” Display= “Hello, Mr. ” + name + “ ” + lname Else if mstatus = “single” Display= “Hello, Ms. ” + name + “ ” + lname Else Display = “Hello, Mrs. “ + name + “ ” + lname;. End

Grade Homework  Create a program that:  Modifies the previous program about the grade average and adds the grade letter to the average display depending on the average. Hello, John Doe You are 12 years old Phone#: Your grade average is 75.3 C