Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Software Development 1Slide 1 Today’s Summary Hello World concepts – –main, static, console Programming patterns involving assignment and.

Similar presentations


Presentation on theme: "Fundamentals of Software Development 1Slide 1 Today’s Summary Hello World concepts – –main, static, console Programming patterns involving assignment and."— Presentation transcript:

1 Fundamentals of Software Development 1Slide 1 Today’s Summary Hello World concepts – –main, static, console Programming patterns involving assignment and conditionals Correcting Compile Time Errors – –Above all don’t panic! Read the error message – –Work through errors one at a time Check adjacent lines Buggy Part 1 Stubs Loops – –For loops while loops do-while loops Summarized on the next few slides

2 Fundamentals of Software Development 1Slide 2 Hello World concepts The next slide shows the entire HelloWorld programThe next slide shows the entire HelloWorld program –It illustrates the following concepts: The main methodThe main method Static methodsStatic methods Console projectsConsole projects How to use System.out.println to print a String to the consoleHow to use System.out.println to print a String to the console Summarized on the next few slides

3 Fundamentals of Software Development 1Slide 3 Hello World – the complete program public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world"); } main is the name of the special method at which any Java application begins A static method is a method that “belongs” to the class instead of to each instance of the class. The static method cannot refer to the class’ non-static fields. The special main method is, by definition, static. System is a class that has “system” stuff System has a public static field called out that is a PrintStream – a thing that can print to the console main has command-line arguments sent as a String array println is a PrintStream method that prints its argument on a line Instructor: run this zipped HelloWorld project HelloWorld project

4 Fundamentals of Software Development 1Slide 4 Programming patterns involving assignment and conditionals  summary temp = x; x = y; y = temp; if (y < 0) { x = -y; } else { x = y; } if (x > y) { z = x; } else { z = y; } swap absolute value maximum of two if (x >= 90) { z = ‘A’; } else if (x >= 80) { z = ‘B’; } else if (x >= 70) { z = ‘C’; } else if (x >= 60) { z = ‘D’; } else { z = ‘F’; } x = x + 1; Increment (for counting) Select from cases Keep these patterns in mind, to help you with similar problems that you encounter

5 Fundamentals of Software Development 1Slide 5 Correcting Compile Time Errors Above all don’t panic!Above all don’t panic! Read the error messageRead the error message Work through errors one at a timeWork through errors one at a time Check adjacent linesCheck adjacent lines

6 Fundamentals of Software Development 1Slide 6 Loops while (condition) { statement; … statement; } for (start; condition; step) { statement; … statement; } do { statement; … statement; } while (condition); while loop for loop do-while loop

7 Fundamentals of Software Development 1Slide 7 for loops versus while loops Typically we use:Typically we use: –for when we know in advance how many times the loop will execute –while when something that happens in the loop determines when the loop exits –do..while when we want a while loop that always does at least one iteration for (int i = 0; i < 7; i = i + 1) { System.out.println (i + " " + i*i); } int i = 0; while (i < 7) { System.out.println (i + " " + i*i); i = i + 1; } The two boxes are equivalent.

8 Fundamentals of Software Development 1Slide 8 What’s Ahead? Before the next session:Before the next session: –Homework is to prepare to ace the test –Catch up, if you are behind Next session:Next session: –Your first try at designing at entire computational community (BallWorld) Suggestion: Routinely do your homework in F-217 (CSSE lab). A student assistant is there every Sunday through Thursday evening, 7 pm to 9 pm, so you can get immediate answers to any questions you might have. Review sessionReview session –Tuesday Mar 29 - 7:00 – 9:00 pm O157 ExamExam –Wednesday Mar 30 7:00 – 9:00 pm –CSSE120-01 (Steve) – O157 –CSSE 120-02 (Salman) – O169


Download ppt "Fundamentals of Software Development 1Slide 1 Today’s Summary Hello World concepts – –main, static, console Programming patterns involving assignment and."

Similar presentations


Ads by Google