Introduction To Programming Wk1
Introduction To Programming Wk1
PROGRAMMING
LECTURE 1
Learning Objectives
The physical machine that you see is the hardware of the computer system.
This physical machine needs a "brain" to make it work, and that is the
• Hardware
the processor (or better known as CPU), main memory (better known as
The computer's processor and the main memory form the heart of
the computer and are usually thought of a one integrated unit.
Software
Software is the program that allows you to "talk" to the computer. First of
all, the computer must have a program which is called the operating system.
The operating system is a special program which was written by experts
and its main purpose is to allow the machine to interact with you. The
operating system controls the computer’s resourсеs. If you want to run a
program, you will tell the operating system the name of the file that contains it,
and the operating system will run the program. This program which you
want to run is called an application program. Application programs can be
programs which you buy, or it can be programs which you write yourself.
Computer systems
There are many different programming languages, each with its own syntax and
purpose. Some popular programming languages include Python, Java, C++,
JavaScript, and so on. Each language has its strengths and weaknesses, making
them suitable for different types of projects.
Overall, programming is a valuable skill that can open up a wide range of career
opportunities in technology and beyond.
How To Design And Write Programs
If you want to write a program, you must first design it. But before you
can do any designing yon must first know what it is that you want and
what you want to achieve. All these are part of a process called the
software development life cycle (SDLC).
You want to write a program that will help user convert US dollar into Leones.
You already determined the output of the program. The output will be to display
the amount in Leones on the computer screen. The input of the program is the
amount of US dollar, keyed in by the user from the keyboard. There is also a
second input, which is the conversion rate. Now you have to figure out the
process that will transform the value of the US dollars into an equivalent
value in Leones. In this example, the process in not very complex. To convert
the value, the computer has to multiply the value of the US dollars by the
conversion rate. We can put these information in an Input-Process-Output
(IPO)table as shown below:
Start
Display “Enter value of US dollars (USD)”
Input USD
Display “Enter the conversion rate”
Input conversionRate
Set Leones =USD x conversionRate
Display “Le “ + Leones
End Program
Flowchart
Parallelogram - For input /output data eg. Read data, display data, print data
Algorithm
Start
Display “Enter value of Km driven”
Input kmDriven
Display “Enter the litre of petrol used”
Input litre_of_petrol
Set km_per_litre = kmDriven / litre_of_petrol
Display km_per_litre
End Program
Exercises
• Sales Prediction
A company has determined that its annual profit is typically 23 percent of total
sales. Design a program that asks the user to enter the projected amount of
total sales, and then displays the profit that will be made from that amount.
Hint: Use the value 0.23 to represent 23 percent.
• Miles-per-Gallon
A car’s miles-per-gallon (MPG) can be calculated with the following formula:
MPG = Miles driven / Gallons of gas used
Design a program that asks the user for the number of miles driven and the
gallons of gas used. It should calculate the car’s miles-per-gallon and display
the result on the screen.