Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Algorithms and Computer Programming. Algorithms algorithm is an ordered sequence of instructions for solving a problem. Look at it as a building blocks."— Presentation transcript:

1 Algorithms and Computer Programming

2 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.

3 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”;

4 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

5 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.

6 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

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

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

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

10 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.

11 Using pseudo code

12

13 abbreviated from American Standard Code for Information Interchange ASCII

14 Ω 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

15

16 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?

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

18 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

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

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

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

22 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

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

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

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

26 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

27 Write a programme to calculate number of strings

28 Write a programme to calculate number days

29 Write a programme to reverse entries


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

Similar presentations


Ads by Google