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

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Fundamentals of Software Development 1Slide 1 Today’s Summary Statements: Conditionals (if-then-else)Statements: Conditionals (if-then-else) Investigated.
Your First Java Program: HelloWorld.java
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Fundamentals of Software Development 1Slide 1 Review: Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote.
Loops For While Do While. Loops Used to repeat something Loop statement creates and controls the loop.
Mock test review Revision of Activity Diagrams for Loops,
REPETITION (loops or iteration) Schneider: Sec. 6.1 & 6.3.
Fundamentals of Software Development 1Slide 1 Programming Patterns: Motivation Many problems fit a “pattern” that experienced software developers recognizeMany.
Fundamentals of Software Development 1Slide 1 Today’s Summary UML class diagrams – –Why classes are important – –UML class diagrams – relationships – –UML.
0 Advanced Selection CE : Introduction to Software Development Week 3 Lecture 2.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Fundamentals of Software Development 1Slide 1 Correcting Compile Time Errors Above all don’t panic!Above all don’t panic! Read the error messageRead the.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Classes and Objects in Java
1 Chapter 2 Introductory Programs. 2 Getting started To create and run a Java program –Create a text file with a.java extension for the source code. For.
University of British Columbia CPSC 111, Intro to Computation 2009W2: Jan-Apr 2010 Tamara Munzner 1 Loops III Lecture 19, Wed Mar
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
 To be able to write larger programs ◦ By breaking them down into smaller parts and passing data between the parts.  To understand the concepts of Methods.
Fundamentals of Software Development 1Slide 1 Today’s Summary Things, types and names – –What are names? types? – –Why use names? – –How to use a name:
10-Aug-15 Classes and Objects in Java. 2 Classes and Objects A Java program consists of one or more classes A class is an abstract description of objects.
Control Structures II. Why is Repetition Needed? There are many situations in which the same statements need to be executed several times. Example: Formulas.
Chapter 4: Control Structures II
Lecture 10 Instructor: Craig Duckett. Assignment 2 Revision TONIGHT DUE TONIGHT Wednesday, August 5 th Assignment 3 NEXT DUE NEXT Monday, August 10 th.
Hello AP Computer Science!. What are some of the things that you have used computers for?
Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first.
Fundamentals of Software Development 1Slide 1 Recap: “From scratch” projects Today’s software engineering is almost NEVER “from scratch”Today’s software.
CompSci 42.1Intro to Java Anatomy of a Class & Terminology Running and Modifying a Program.
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
Fundamentals of Software Development 1Slide 1 Today’s summary Attitudes toward learning:Attitudes toward learning: –Working in groups –Learning by doing.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
Lecture 2: Classes and Objects, using Scanner and String.
Fundamentals of Software Development 1Slide 1 Loops A loop is:A loop is: –a block of code that executes repeatedly while some condition holds true. Java.
Flow Control in Java. Controlling which instruction to execute next Sequential  Similar to walking, one step after another Branching  Similar to a fork.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 6 l Array Basics l Arrays and Methods l Programming with Arrays.
Chapter 5: Control Structures II J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design,
OOP in Java : © W. Milner 2005 : Slide 1 Java and OOP Part 2 – Classes and objects.
Repetition Statements while and do while loops
Anatomy.1 Anatomy of a Class & Terminology. Anatomy.2 The Plan Go over MoveTest.java from Big Java Basic coding conventions Review with GreeterTest.java.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Fundamentals of Software Development 1Slide 1 Programming Patterns Many problems fit a “pattern” that experienced software developers recognizeMany problems.
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
Fundamentals of Software Development IProgramming patterns involving iteration1 Overview LoopsOverview Loops We’ll also see how loops are often combined.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
Lab 01-2 Objectives:  Writing a Java program.  How to send output to the command line console.  Learn about escape sequences.  Learn how to compile,
Introduction to Computing Concepts Note Set 15. JOptionPane.showMessageDialog Message Dialog Allows you to give a brief message to the user Can be used.
Fundamentals of Software Development 1Slide 1 Loops A loop is:A loop is: –a block of code that executes repeatedly while some condition holds true. Java.
CIT 590 Intro to Programming Lecture 13. Some Eclipse shortcuts CTRL + SHIFT + F – format file (proper indentation etc). Please do this before you submit.
CMSC 150 LOOPS CS 150: Fri 20 Jan Representing DNA AGTCCAGTGTCAA.
Fundamentals of Software Development 1Slide 1 Programming Patterns Many problems fit a “pattern” that experienced software developers recognizeMany problems.
Jeopardy $100 VariablesErrorsLoops Classes and Objects Program Structure $200 $300 $400 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400 $300.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
LOOPS CHAPTER Topics  Four Types of Loops –while –do…while –for –foreach  Jump Statements in Loops –break –continue 2.
Lecture 4: For Loops Announcements & Review Announcements Examples posted after lecture on schedule Discussion Section exercises on line before 9am Tuesdays.
Loops, Part II IT108 George Mason University. Indefinite Loop Don’t always have access to the number of iterations ahead of time If a condition (user-response,
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Object Oriented Programming Lecture 2: BallWorld.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Loops A loop is: Java provides three forms for explicit loops:
Object-Oriented programming for Beginners LEAPS Computing 2015
Chapter 5: Control Structures II
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
CHAPTER 21 LOOPS 1.
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
In this class, we will cover:
Presentation transcript:

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

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

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

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

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

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

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.

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 :00 – 9:00 pm O157 ExamExam –Wednesday Mar 30 7:00 – 9:00 pm –CSSE (Steve) – O157 –CSSE (Salman) – O169