CS1211 Computer Programming (1) : Introduction To High-Level Programming Languages
CS1211 Computer Programming (1) : Introduction To High-Level Programming Languages
• Grading:
2
Course Information
5
Course Description
6
Course Main Objective
7
Course Learning Outcomes
Skills:
• Design basic objects.
• Analyze programming problems and implement programs that
realize the required logic.
• Use the command line and relevant IDEs for writing,
formatting, compiling, running, and debugging code.
8
Course Syllabus
• Introduction to high-level programming languages (general
background, programming errors, coding styles, and how to edit,
compile, and run programs in relevant IDE)
• Variables, data types, assignment statements, constants, data type
conversions, arithmetic expressions, and the String type
• Input/output
• Control statements and Boolean expressions
• Loops and repetition structures
• Methods and using parameters
9
Chapter 1: Introduction to high-level programming
languages
• General background.
• Programming errors.
• Coding styles.
• How to edit, compile, and run programs in relevant
IDE.
10
Hardware and Software
• Computer systems consist of hardware and
software.
– Hardware includes the tangible parts of computer
systems.
– Software includes programs - sets of instructions for
the computer to follow.
• Familiarity with hardware basics helps us
understand software.
Hardware and Memory
• Most modern computers have similar
components including
– Input devices (keyboard, mouse, etc.)
– Output devices (display screen, printer, etc.)
– A processor
– Two kinds of memory (main memory and auxiliary
memory).
The Processor
• Also called the CPU (central processing unit) or
the chip (e.g. Pentium processor)
• The processor processes a program’s
instructions.
• It can process only very simple instructions.
• The power of computing comes from speed and
program intricacy.
Memory
• Memory holds
– programs
– data for the computer to process
– the results of intermediate processing.
• Two kinds of memory
– main memory
– auxiliary memory
Main memory
• Working memory used to store
– The current program
– The data the program is using
– The results of intermediate calculations
• Usually measured in megabytes (e.g. 8
gigabytes of RAM)
– RAM is short for random access memory
– A byte is a quantity of memory
Auxiliary Memory
• Also called secondary memory
• Disk drives, CDs, DVDs, flash drives, etc.
• More or less permanent (nonvolatile)
• Usually measured in gigabytes (e.g. 50 gigabyte
hard drive)
Bits, Bytes, and Addresses
• A bit is a digit with a value of either 0 or 1.
• A byte consists of 8 bits.
• Each byte in main memory resides at a
numbered location called its address.
Main Memory
• Figure 1.1
Storing Data
• Data of all kinds (numbers, letters, strings of
characters, audio, video, even programs) are
encoded and stored using 1s and 0s.
• When more than a single byte is needed,
several adjacent bytes are used.
– The address of the first byte is the address of the unit
of bytes.
Files
• Large groups of bytes in auxiliary memory are
called files.
• Files have names.
• Files are organized into groups called directories
or folders.
• Java programs are stored in files.
• Programs files are copied from auxiliary memory
to main memory in order to be run.
0s and 1s
• Machines with only 2 stable states are easy to
make, but programming using only 0s and 1s is
difficult.
• Fortunately, the conversion of numbers, letters,
strings of characters, audio, video, and
programs is done automatically.
Programs
• A program is a set of instructions for a computer
to follow.
• We use programs almost daily (email, word
processors, video games, bank ATMs, etc.).
• Following the instructions is called running or
executing the program.
Input and Output
• Normally, a computer receives two kinds of
input:
– The program
– The data needed by the program.
• The output is the result(s) produced by following
the instructions in the program.
Running a Program
• Figure 1.2
Sample
screen
output
Some Terminology
• The person who writes a program is called the
programmer.
• The person who interacts with the program is
called the user.
• A package is a library of classes that have been
defined already.
– import java.util.Scanner;
Some Terminology
• The item(s) inside parentheses are called
argument(s) and provide the information needed
by methods.
• A variable is something that can store data.
• An instruction to the computer is called a
statement; it ends with a semicolon.
• The grammar rules for a programming language
are called the syntax of the language.
Printing to the Screen