BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)

Slides:



Advertisements
Similar presentations
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
Advertisements

Internal Documentation Conventions. Kinds of comments javadoc (“doc”) comments describe the user interface: –What the classes, interfaces, fields and.
CS 106 Introduction to Computer Science I 02 / 29 / 2008 Instructor: Michael Eckmann.
Two examples of Problem Solving in Programming H. Chad Lane University of Pittsburgh CS7: Introduction to Programming.
Lecture 17 Instructor: Craig Duckett Passing & Returning Arrays.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Introduction to Arrays.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Software Development Software Life Cycle UML Diagrams.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
CS 106 Introduction to Computer Science I 02 / 28 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 03 / 03 / 2008 Instructor: Michael Eckmann.
CS 201 Functions Debzani Deb.
Top-Down Design with Functions 4 What do programmer’s (not programs!) use as input to the design of a program? –Documentation Problem definition Requirements.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
CS 106 Introduction to Computer Science I 10 / 15 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 10 / 16 / 2006 Instructor: Michael Eckmann.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Games and Simulations O-O Programming in Java The Walker School
Welcome to CompSci 100! As You Arrive… Make sure you grab a syllabus packet. Read through it. I will be covering the most essential points in my talk,
METHODS Introduction to Systems Programming - COMP 1005, 1405 Instructor : Behnam Hajian
COMP 111 Programming Languages 1 First Day. Course COMP111 Dr. Abdul-Hameed Assawadi Office: Room AS15 – No. 2 Tel: Ext. ??
Java: Chapter 1 Computer Systems Computer Programming II.
Introduction to Algorithm Design and Documentation CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Modular Programming Chapter Value and Reference Parameters computeSumAve (x, y, sum, mean) ACTUALFORMAL xnum1(input) ynum2(input) sumsum(output)
Triangulation Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
Java Classes Using Java Classes Introduction to UML.
Introduction of Engineering (ENGR 10) Guest Lecture March 24, 2014.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
October, 2006 © Copyright 2006, Larry A. Beaty. Copying and distribution of this document is permitted in any medium, provided this notice is preserved.
Methods in Java CSC1401. Overview In this session, we are going to see how to create class-level methods in Java.
Object Oriented Programming Elhanan Borenstein copyrights © Elhanan Borenstein.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
CIT 590 Intro to Programming First lecture on Java.
CS 101: Introduction to computer programming and utilization Abhiram Ranade.
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
Making Decisions uCode: October Review What are the differences between: o BlueJ o Java Computer objects represent some thing or idea in the real.
 A Collection class is a data type that is capable of holding a group of items.  In Java, Collection classes can be implemented as a class, along with.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
1 Flight Times. 2 Problem Specification 3 Additional Specifications You may assume that the input is a valid 24 hour time. Output the time entered by.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
1 CS161 Introduction to Computer Science Topic #9.
Introduction Chapter 1 8/31 & 9/1 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
1 Structure of a C Program (continued) Presentation original from Dr. Turner’s class USF - COP C for Engineers Summer 2008.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
CS 106 Introduction to Computer Science I 03 / 02 / 2007 Instructor: Michael Eckmann.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Introduction Chapter 1 1/22/16. Check zyBooks Completion Click on the boxes for each section.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
CMSC 2021 Software Development. CMSC 2022 Software Development Life Cycle Five phases: –Analysis –Design –Implementation –Testing –Maintenance.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Announcements You will receive your scores back for Assignment 2 this week. You will have an opportunity to correct your code and resubmit it for partial.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
© Janice Regan, CMPT 128, January CMPT 128: Introduction to Computing Science for Engineering Students Introduction to Arrays.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
Introduction to Computing Systems and Programming Programming.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Week91 APCS-A: Java Problem Solving November 2, 2005.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana Pronounced Bah-bah Co-fee Way-ou-see-jah-nah Call him “Baba” or “Dr. Weusijana”
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana Pronounced Bah-bah Co-fee Way-ou-see-jah-nah Call him “Baba” or “Dr. Weusijana”
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana Pronounced Bah-bah Co-fee Way-ou-see-jah-nah Call him “Baba” or “Dr. Weusijana”
BIT 115: Introduction To Programming
Chapter 7: User-Defined Functions II
BIT 115: Introduction To Programming
Week 4 Lecture-2 Chapter 6 (Methods).
Presentation transcript:

BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)

BIT 115: Introduction To Programming 2 Quiz 15 hington.edu/webq/surve y/babaw/ hington.edu/webq/surve y/babaw/

BIT 115: Introduction To Programming Today… Arrays again (passing, using) –Ch ICE 15 on website Stepwise Refinement, Pseudocode –Ch No class Monday (Memorial Day) More on Arrays, Stepwise Refinement, and Pseudocode on Wednesday

BIT 115: Introduction To Programming 4 Careful thinking What makes programming difficult isn't the typing –Isn't not the Java language –It's not getting the computer to work It's the level of detail that the computer forces you to think at –Simultaneously high-level to figure out the big picture –All the way down to the nitty-gritty, to figure out individual services. You need to think through the problems, very carefully –With a fine-toothed comb 4

BIT 115: Introduction To Programming 5 Stepwise Refinement A good general process for doing both top- down design and bottom-up design together See 3.2.8, p. 132 Use pseudocode in TODO comments to document your plans along with method stubs –Then begin implementing them leaving the comments there and updating them if your plans change –Avoids forgetting & getting lost! –Comments easy to convert to JavaDoc 5

BIT 115: Introduction To Programming 6 Software Design Questions to Ask Yourself What’s the big picture? What are we trying to DO (usually solving a problem) for some USER? –What should the user experience? What classes do we need for that? –What classes from Sun or 3rd party (like Becker) do I need to import (check JavaDoc websites)? –For the remaining classes I must write, what methods/services should be in those classes? How do we implement those with code? What code like that have I seen before (from a book, website, previous code I wrote) and can copy and rewrite for my needs? UP DOWN

BIT 115: Introduction To Programming 7 Working in BIT115 NEVER remove a comment I put into an assignment! You can write another comment under it to explain why you didn’t do it –Why you failed to do it –Why my plan was in error –Either way you should ask me a question in- person or via after checking with the instructions, textbook, JavaDocs, and partner! 7

BIT 115: Introduction To Programming 8 ICE 15 int[] longArray = new int[14]; // We want to put numbers into the long array in reverse order. // We should thus count DOWN through the slot numbers (with arrayIndex), // and simultaneously have a counter (increasingCounter) count UP. int increasingCounter = 0; for (int arrayIndex = longArray.length - 1; arrayIndex >= 0; arrayIndex--) { longArray[arrayIndex] = (increasingCounter + 1) * 3; increasingCounter++; } 8

BIT 115: Introduction To Programming 9 ICE 15 int[] longArray = new int[14]; // We want to put numbers into the long array in reverse order. // We should thus count DOWN through the slot numbers (with arrayIndex), // and simultaneously have a counter (increasingCounter) count UP. int increasingCounter = 0; for (int arrayIndex = longArray.length - 1; arrayIndex >= 0; arrayIndex--) { longArray[arrayIndex] = (increasingCounter + 1) * 3; increasingCounter++; } 9

BIT 115: Introduction To Programming 10 Passing An Array To A Method 2 parts: 1.Declaring the parameter In the parameter list, put the [] after the type, similar to declaring one as a variable 2.Passing the array to the method (service) Make sure NOT to include () after the name of the array argument Example: public void printArray(int [] array) { int i; for(i = 0; i < array.length; i++) { System.out.println(array[i]); } Note that arrays are always passed by reference 10

BIT 115: Introduction To Programming 11 Returning An Array From A Method 2 parts: 1.Declaring the return type In the parameter list, put the [] after the type, similar to declaring one as a variable 2.Returning the array Make sure NOT to include () after the name of the array argument Example: public int[] createArray(int howMany) { int [] newArray = new int[howMany]; return newArray; } Note that arrays are always passed by reference 11