PT - Why Programming? Why Java? (Lesson)
Why Programming? Why Java?
What is Computer Programming?
How do you make a peanut butter and jelly sandwich? Imagine you are telling someone how to make it but you cannot do anything to help. All you can do is tell the person what to do. Oh, and the person making the sandwich doesn’t know anything at all. You must explain everything in detail. Every detail matters. As in, open the jelly…use a knife to spread it on a slice of bread… If you skip a step it could be a mess. Imagine a sandwich with no bread…spreading peanut butter without a knife…jelly on the outside of the sandwich. It could get sticky!
Computer programming is creating a set of instructions to get a computer to respond in a certain way. (Oh, and the computer knows nothing…well not really, but it certainly doesn’t know what you know.) Computers have no judgement or ability to make decisions, so your instructions need to be very clear.
Java Basics
Let’s look at the skeleton of a basic Java program:
Now this doesn’t look very interesting because it isn’t. There is nothing in the body of the program, however, from this we can see the basic structure of a Java program, called a class.
All programs start with a class. In this example, the class name is Skeleton. Skeleton is just a name – you could put anything in its place.
Important!
(We will learn more about that later.)
The green portion behind the // is where the comments go. Comments appear throughout the program. "end of class" is an example of a comment. Comments can be anything you want humans to read when they read your code. You might put your name in comments when completing a programming assignment or you might write an explanation about code on that line.
The body of the program will go between the two curvy brackets.
Dr. Java Output Activity
Try this in Dr. Java.
Click in the rectangle below to continue.
Snoopy Test Activity
Click on each tab below to view statements to test in Dr. Java. Check the output. Click below to begin.
Click on "Runestone Academy" below to open the required reading that is listed.
Runestone Academy Links to an external site.: AP CSA – Java Review:
READ: 2.1 – What is Java?
Dr. Java
Please complete the Dr. Java activity below. Begin by clicking on the title in the box below.
IMAGES CREATED BY GAVS