Algorithms and Computer Programming. Algorithms algorithm is an ordered sequence of instructions for solving a problem. Look at it as a building blocks.

Slides:



Advertisements
Similar presentations
Chapter 8 Improving the User Interface
Advertisements

Introduction to Programming in C++ John Galletly.
Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
1 Various Methods of Populating Arrays Randomly generated integers.
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:
ITEC113 Algorithms and Programming Techniques
OBJECT-ORIENTED PROGRAMMING CONCEPTS (Review). What is an Object? What is an Object? Objects have states and behaviors. Example: A dog has states - color,
Week 2: Primitive Data Types 1.  Programming in Java  Everything goes inside a class  The main() method is the starting point for executing instructions.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
Program Design and Development
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
Pseudocode.
Pseudocode.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
Computer Programming Lab(4).
Python quick start guide
Python.
Intro to Java Programming  A computer follows the instruction precisely and exactly.  Anything has to be declared and defined before it can be used.
Object Oriented Software Development
Agenda Review Compiling Review Data Types Integer Division Composition C++ Mathematical Functions User Input Reading: , 8.11 Homework #3.
Introduction to Python
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Java Classes Methods Objects. Classes Classes We have been using classes ever since we started programming in Java Whenever we use the keyword class.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
BUILDING JAVA PROGRAMS CHAPTER 7 Arrays. Exam #2: Chapters 1-6 Thursday Dec. 4th.
Repetition & Loops. One of the BIG advantages of a computer: ­It can perform tasks over and over again, without getting bored or making mistakes (assuming.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Review, Pseudocode, Flow Charting, and Storyboarding.
Object-Oriented Programming •Object-Oriented Programming (OOP) allows you to create your program based upon modeling objects.  Your program’s properties.
Classes and Methods. Classes Class Definition Data Fields –Variables to store data items –Differentiate multiple objects of a class –They are called.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
JAVA CLASSES, METHODS AND VARIABLES.  Defined Noun: A set or category of things having some property or attribute in common and differentiated from others.
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Chapter 9 Introduction to Arrays Fundamentals of Java.
CS100Lecture 61 Announcements Homework P1 due on Thursday Homework P2 handed out.
Introduction to Object-oriented Programming
Introduction to Algorithms
Objects as a programming concept
3.1 Fundamentals of algorithms
Computer Programming.
ALGORITHMS AND FLOWCHARTS
Subroutines Idea: useful code can be saved and re-used, with different data values Example: Our function to find the largest element of an array might.
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
CPS120: Introduction to Computer Science
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
Java Programming Loops
The University of Texas – Pan American
ALGORITHMS AND FLOWCHARTS
Programming We have seen various examples of programming languages
Introduction to Algorithms
Creating Computer Programs
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Java Programming Loops
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
Creating Computer Programs
CPS120: Introduction to Computer Science
Presentation transcript:

Algorithms and Computer Programming

Algorithms algorithm is an ordered sequence of instructions for solving a problem. Look at it as a building blocks consist of variables, subroutines, parameters, conditionals, and repetition.

Variables: Named values variables give us the ability to refer to values unambiguously. Another way to think of a variable is like a named box that stores a value. For instance int x = 5; String x = “hello”;

Conditionals: Handling different situations Get the algorithms to do different things depending on whether certain things are true or not if something is true: then do something else: do something else

Repetition Sometimes we need our algorithm to do things again and again. Repeat action(s) until a desired condition is met. While some condition is met, repeat action(s). Repeat action(s) a fixed number of times.

Subroutines: Named helper algorithms Many algorithms require the use of some common, or more basic, operations. In fact, most algorithms we write refer to some other algorithms. For instance, in an algorithm that keeps track of how many times a repeated action has occurred, we may want to increment, or add one to some counter variable, as in counter = 1 + counter

Parameters: Named inputs start = input("Enter a number: ")

constant cannot be changed during the execution of the program int x = 5; int z = x + 2

Parameter passed to the subroutine String x = “Z is = ” ; int z = 6 System.out.print(x + z);

differentiating between a function and a procedure. A function returns a value and a procedure just executes commands. function comes from math. It is used to calculate a value based on input. A procedure is a set of command which can be executed in order.

Using pseudo code

abbreviated from American Standard Code for Information Interchange ASCII

Ω or kΩ Ohms to kilo ohms 100 Ω = 0.1 kΩ 1000 Ω= 1 kΩ From Ω to kΩ divide by 1000 From kΩ to Ω multiply by a 1000

Objects All objects have state and behaviour. Dogs have state (name, colour, breed) and behaviour(barking, fetching, eating). Bicycles also have state (current gear, pedal, colour) and behaviour (Changing gear, brakes). What state can objects have? What behaviours can objects perform?

Software objects States (variables, methods, programming language) Behaviours (functions, transactions)

Class There are thousands of bicycles with same models and make, each bicycle build from the same set of blueprints Class is the blueprint of the objects you created Example Bicycle is an instance of class objects bicycles

Public class Bicycle int speed = 0; int value ; int increamnetspeed; String model;

Inheritance Classes are allowed to inherent from the super classes Example Bicycle Superclass Mountain bike and Road bike inherence from bicycle

Method start = input("Enter a number: ") System.out.println(“Text”); Parameters: Named inputs

Attributes in Computing An attribute is another term for a field. It's typically a public constant or a public variable that can be accessed directly. In this particular case, the array in Java is actually an object and you are accessing the public constant value that represents the length of the array. In computing, an attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such. An attribute is frequently and generally a property of a property. However, in actual usage, the term attribute can and is often treated as equivalent to a property depending on the technology being discussed.computingvalue

int x = 10; Variable Value of Double Temperature = 36.9

Scanner input = new Scanner(System.in); String number = input.nextLine();

Write a program to convert the weather temperature from Celsius (°C) / Fahrenheit (°F) Conversion

Write a program to find the area of a circle First you ask the user to input radius The out put Radius * Radius *3.14 PI: 3.14 NO numbers should be used in RESULT

Write a programme to calculate number of strings

Write a programme to calculate number days

Write a programme to reverse entries