Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java: Chapter 1 Computer Systems Computer Programming II.

Similar presentations

Presentation on theme: "Java: Chapter 1 Computer Systems Computer Programming II."— Presentation transcript:

1 Java: Chapter 1 Computer Systems Computer Programming II

2 Why Java? A good question before we even begin looking at the Java language. The answer is that Java enables users to develop and deploy applications on the Internet for servers, desktop computers, and small hand-held devices. The future of computing is being profoundly influenced by the Internet, and Java promises to remain a big part of that future.. F Java is a general purpose programming language. F Java is the Internet programming language.

3 What About Java? James Gosling and Sun Microsystems created and distributed Java Java was released on May 20, 1995 as a free program and has grown into one of the most popular programming languages in the world. Java can be downloaded along with the program(JCreator) we will use to work with Java from free. Instructions can be found on my school web page with links to the download sites.

4 Java a Problem Solver???? The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the problem –Dissect the problem into manageable pieces –Design a solution –Consider alternatives to the solution and refine it –Implement the solution –Test the solution and fix any problems that exist –Example You walk out to your car insert the key into the ignition and nothing happens…Solve this problem using the above steps.

5 Problem Solving Many projects fail because the developer/repair person didn't really understand the problem to be solved.

6 Java Program Structure As a class lets create your first java program which in located on page 27 and is called the Lincoln program. To create the program follow the instructions within the word document that has illustrated instructions and hints for success.

7 Lets Create another program To practice our java programming skills lets use the Lincoln program as a model and create a program that displays that following… Name Address DOB Phone Number The program should be named Personal

8 Java vs. Visual Basic Create a program in visual basic that displays the same output as the Lincoln program that was just created in Java. Remember in VB you will use labels and a command button to make your program work correctly.

9 Java vs. Visual Basic What are some of the similarities between Java and Visual Basic? What are some of the differences between Java and Visual Basic?

10 10 Main Parts of a Java Program public class MyProgram {}{} // comments about the class class header class body Comments can be placed almost anywhere, comments are short descriptive statements About your program or lines of code.

11 11 Main Parts of a Java Program public class MyProgram {}{} public static void main (String[] args) {}{} // comments about the class // comments about the method method header method body Main Method

12 12 Comments Comments should be included to explain the purpose of the program and describe processing steps They do not affect how a program works Java comments can take three forms: // this comment runs to the end of the line /* this comment runs to the terminating symbol, even across line breaks */ /** this is a javadoc comment */

13 Assignment Using the Lincoln program on page 27 as an example design a program(You decide the name of the program) that produces your favorite quote as output and also tells who made the quote. Inside of your program insert comments that will identify the following sections within your program 1) Main Method 3) Class Header 4)Class Body 5) Method Header 6)Method Body Turn the printout of your code in for a 50 point grade. Make sure your name is included.

14 14 Identifiers Identifiers are the words a programmer uses in a program and can change from program to program and programmer to programmer. Java is case sensitive(uppercase and lowercase make words different) - Total, total, and TOTAL are 3 different identifiers. In Visual Basic they would all be the same identifier.

15 Identifiers Often we use special identifiers called reserved words that already have a predefined meaning in the language A reserved word cannot be used in any other way

16 16 Reserved Words The Java reserved words(as found on page 31 of the text): abstract boolean break byte case catch char class const continue default do double else extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while

17 17 White Space Spaces, blank lines, and tabs are called white space White space is used to separate words and symbols in a program Extra white space is ignored A valid Java program can be formatted in many ways Programs should be formatted to enhance readability, using consistent indentation See (page 33) See (page 34)

18 Basic Program Development errors Edit and save program Compile program Execute program and evaluate results

19 Representing Color A black and white picture can be stored using one bit per pixel (0 = white and 1 = black) A colored picture requires more information; there are several techniques for representing colors For example, every color can be represented as a mixture of the three additive primary colors Red, Green, and Blue In Java, each color is represented by three numbers between 0 and 255 that collectively are called an RGB value

20 Coordinate Systems Each pixel can be identified using a two- dimensional coordinate system When referring to a pixel in a Java program, we use a coordinate system with the origin in the top- left corner to help place objects within the computer screen area. 112 Y X(0, 0) (112, 40) 40

21 End of the Chapter Challenge Programs – 250 Points Complete the following programs found in the Java Textbook on page 52-53. Programming Project 1.1 and 1.2, make sure project 1.1 is working correctly before introducing any errors. Write down the error message or why the program worked.(50 points) Programming Projects 1.3,1.4, 1.5 and 1.6(50 points each)

Download ppt "Java: Chapter 1 Computer Systems Computer Programming II."

Similar presentations

Ads by Google