Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions.

Similar presentations


Presentation on theme: "Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions."— Presentation transcript:

1 Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions form an algorithm

2 Why Program? Computers are tools that can be programmed to perform many functions. Computers are versatile because they can be programmed. Implement ______________________ to solve problems or calculate answers to problems, listen to music …

3 Why Program? Computers are tools that can be programmed to perform many functions. Computers are versatile because they can be programmed. Implement algorithms to solve problems or calculate answers to problems, listen to music …

4 What to Program? Aspects of a computer program that must be designed:
The logical flow of the instructions The mathematical procedures The layout of the programming statements The appearance of the screens The way information is presented to the user The program’s “user friendliness”

5 How to Program? Programs must be analytically correct.
Programs rarely work the first time they are programmed. Programmers must perform the following on a continual basis: analyze, experiment, correct, and redesign. Programming languages have strict rules, known as syntax, that must be carefully followed.

6 Programming Languages
In order to understand a program, the computer needs the program to be written in machine language. Machine language is written using binary numbers. The binary numbering system (base 2) only has two digits (0 and 1). Example machine language computer code: Problem? Machine language for a Mac CPU is not the same as the machine language as an Intel CPU. Different processors have different machine languages

7 Programming Languages
In the distant past, programmers wrote programs in machine language. Programmers developed higher level programming languages to make things easier. Some common programming languages: BASIC COBOL Pascal C C++ Java

8 Morgan Kaufmann Publishers
April 23, 2017 A Bit On Java First Developed by Sun Microsystems in 1991 There was a need for a programming language that would run on various devices. Ideal for internet browsers Java incorporated into Netscape in 1995 Java is “cross platform”, meaning that it can run on various computer operating systems. Chapter 1 — Computer Abstractions and Technology

9 How does Java work? A programmer writes Java programming statements for a program. These statements are known as source code. A text editor is used to edit and save a Java source code file. (We will use Jcreator) Source code files have a .java file extension. A ___________ is a program that translates source code into an executable form.

10 How does Java work? A programmer writes Java programming statements for a program. These statements are known as source code. A text editor is used to edit and save a Java source code file. (We will use Jcreator) Source code files have a .java file extension. A compiler is a program that translates source code into an executable form.

11 The Compiler and the Java Virtual Machine
A compiler is run using a source code file as input. Syntax errors are mistakes that the programmer has made that violate the rules of the programming language. Discovered at “compile time” The compiler creates another file that holds the translated instructions.

12 The Compiler and the Java Virtual Machine
The Java compiler translates a Java source file into a file that contains byte code instructions. Files end with at .class extension Byte code instructions are the machine language of the Java Virtual Machine (JVM) and cannot be directly executed directly by the CPU.

13 Program Development Process
Text editor Source code (.java) Saves Java statements Java compiler Is read by Byte code (.class) Produces Java Virtual Machine Is interpreted by Program Execution Results in

14 Portability A program is ___________________________ if it may be written on one type of computer and then run on a wide variety of computers, with little or no modification. Java byte code runs on the JVM and not on any particular CPU; therefore, compiled Java programs are highly portable. JVMs exist on many platforms: Windows Mac Linux

15 Portability A program is __portable________________ if it may be written on one type of computer and then run on a wide variety of computers, with little or no modification. Java byte code runs on the JVM and not on any particular CPU; therefore, compiled Java programs are highly portable. JVMs exist on many platforms: Windows Mac Linux

16 Portability With most programming languages, portability is achieved by compiling a program for each CPU it will run on. Java provides an JVM for each platform so that programmers do not have to recompile for different platforms.

17 Portability Byte code (.class) Java Virtual Machine for Windows
Machine for Unix Java Virtual Machine for Linux Java Virtual Machine for Mac

18 How To Program (Our way)
1. Understand the problem 2. Visualize 3. Write down the algorithm on paper Informal high-level description of an algorithm Step1: … Step2: … 4. Translate to Java 5. Save and Compile 6. If does not compile then fix error, save and compile. 7. Run 8. Test code to make sure it works for all expected input


Download ppt "Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions."

Similar presentations


Ads by Google