Programming Concepts
What is data?

We have said that software is the instructions and data that tell the computer what to do.

But what is data?

Remember that we've talked about how computers can perform arithmetic.
Think of the mathematical operations of add, subtract, multiply, and divide as the "instructions".
Then the "data" are the numbers that are added, subtracted, etc. (By the way, the word "data" is plural. The singular of data is "datum".) Most of the time those numbers represent information that people care about.

For example, think about a cash register at your local grocery store.
One purpose of the cash register is to add up the prices of each item you are buying.
The prices are the "data" and the addition operations are the "instructions".
To get a better understanding of what data is, let's try to write a program for the cash register.

Depending on what computer language we are using, all programs will have some things in common.
That is the main purpose of a "Hello, world!" program -
to show the simplest program that we can write in that language.
Here again is the "Hello, world!" program, as written in the Java programming language.

A "String" is a series of characters that the computer language compiler recognizes as a group.

The characters "Hello", in the first line of "Hello, world!" are a string.
In this case they are a name - the name of our program.
In a computer program we often have things that we want to give a name to.
The way we do that is to use a string - a series of characters recognized by the computer.

The other two strings on the first line are "public" and "class".
These are examples of what are called "reserved words".

Reserved Word is a string that has a special meaning defined in a particular computer language.

Each computer language has a set of reserved words - words that have special meaning in that language. Because they have special meanings, reserved words are not used for names.
Later on I will explain what the special meanings are.
For now, I just what you to realize that when you see a program,
some of the words (strings) are a part of the computer language,
while others are names that the programmer created.

Since this is a new program we are writing, the first name we will create is a new name for the program.
It is a good idea to use a name that is descriptive.
For example, we could use the name "Whq1px" for our program. It is a valid name,
as far as the computer is concerned, but it doesn't mean much to a person reading the program.
A better name would be "CashRegister", because that tells the reader what this program does.
So now, the first line of our new program is

public class CashRegister {

Let's suppose we are buying three items: milk, bread, and my favorite, ice cream.
Each of them has a price that we need to store in the computer.
The prices will be stored in memory. Do you remember how, in an earlier lesson, we learned that every memory location has an address?
To get a number in or out of a memory location we have to know its address.
Sometimes we use the actual numerical address of the memory, but more often we use a name for it.

To do that, we have to tell the computer how much memory we need,
what name we want to call it, and what kind of number (data) we what to put in it.
Java has some reserved words that let us do just that.

Notice the 3 new lines I added. What I've done is "declare" three "variables". A variable is a storage location in a computer's memory.

I've used names ("Milk", "Bread", "IceCream") that are easy to understand. I plan to store the price of each item in the memory location that has that name. The word "int" is a reserved word that tells the computer what type of number I will store in that memory location.

Each of the three lines that declare the variables ("Milk", "Bread", "IceCream" is called a statement. In Java, as in many computer languages, every statement ends with the ";" (semicolon). Computer languages use punctuation to determine meaning, just like English and other natural languages do. You can think of a statement as like a sentence in English. An English sentence usually ends in a "." (period). A Java statement always ends in a ";" (semicolon). We will learn about several different types of Java statements in the next few lessons. A Statement expresses a complete instruction to the computer to do something.

There is still alot more work to do on this program, so we will continue with it tomorrow.

Copyright © 2005 by StrongTower Software Inc. All Rights Reserved.

Visit us at