Topic 7 Nested Loops Case Study

Slides:



Advertisements
Similar presentations
Nested for loops Cont’d. 2 Drawing complex figures Use nested for loops to produce the following output. Why draw ASCII art? –Real graphics require a.
Advertisements

Chapter 2: Algorithm Discovery and Design
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
CS305j Introduction to ComputingNested For Loops 1 Topic 6 Nested for Loops "Complexity has and will maintain a strong fascination for many people. It.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Programming Logic and System Analysis
Writing algorithms using the while-statement. Previously discussed Syntax of while-statement:
Building Java Programs
Derived from Building Java Programs by Stuart Reges & Marty Stepp
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Computer Science: A Structured Programming Approach Using C A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-3: Loop Figures and Constants reading: self-checks: 27 exercises:
Control Structures (A) Topics to cover here: Introduction to Control Structures in the algorithmic language Sequencing.
Topic 19 file input, line based Copyright Pearson Education, 2010 Based on slides bu Marty Stepp and Stuart Reges from
1 BUILDING JAVA PROGRAMS CHAPTER 2 Pseudocode and Scope.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 1: Introduction.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 4: Loop Figures and Constants reading:
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Topic 6 loops, figures, constants Based on slides bu Marty Stepp and Stuart Reges from "Complexity has and will maintain.
CS305j Introduction to Computing More Conditional Execution 1 Topic 13 More Conditional Execution " Great dancers are not great because of their technique;
Copyright 2008 by Pearson Education 1 Nested loops reading: 2.3 self-check: exercises: videos: Ch. 2 #4.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
CS305j Introduction to Computing Parameters and Methods 1 Topic 8 Parameters and Methods "We're flooding people with information. We need to feed it through.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 2: Primitive Data and Definite Loops.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
CS305j Introduction to Computing Parameters Case Study 1 Topic 10 Parameters Case Study " Thinking like a computer scientist means more than being able.
An Introduction to Programming with C++ Sixth Edition Chapter 8 More on the Repetition Structure.
Topic: Python’s building blocks -> Variables, Values, and Types
Key Ideas from day 1 slides
GC101 Introduction to computers and programs
Building Java Programs
CSCI 161 – Introduction to Programming I William Killian
Algorithm and Ambiguity
Unit 2 Smarter Programming.
Topic 5 for Loops -Arthur Schopenhauer
Algorithm and Ambiguity
Introduction to the C Language
Learning to Program in Python
Programming Funamental slides
CSc 110, Autumn 2016 Lecture 5: Loop Figures and Constants
CSc 110, Spring 2017 Lecture 4: Nested Loops and Loop Figures
Building Java Programs
CSc 110, Spring 2018 Lecture 7: input and Constants
Hour of Code.
Building Java Programs
CSc 110, Spring 2018 Lecture 5: Loop Figures and Constants
Topic 6 loops, figures, constants
Building Java Programs
Introduction to C.
Building Java Programs
CS 1111 Introduction to Programming Spring 2019
Lecture 7 Algorithm Design & Implementation. All problems can be solved by employing any one of the following building blocks or their combinations 1.
Tonga Institute of Higher Education IT 141: Information Systems
Building Java Programs
Building Java Programs
Tonga Institute of Higher Education IT 141: Information Systems
Suggested self-checks:
Building Java Programs
Drawing complex figures
Topic 19 file input, line based
Review of Previous Lesson
Building Java Programs
Building Java Programs
CIS 110: Introduction to Computer Programming
Concept Development and End Product Description
Chapter 2 Lecture 2-3: Loop Figures and Constants reading:
Presentation transcript:

Topic 7 Nested Loops Case Study "Composing computer programs to solve scientific problems is like writing poetry. You must choose every word with care and link it with the other words in perfect syntax. There is no place for verbosity or carelessness. To become fluent in a computer language demands almost the antithesis of modern loose thinking. It requires many interactive sessions, the hands-on use of the device. You do not learn a foreign language from a book, rather you have to live in the country for year to let the language become an automatic part of you, and the same is true for computer languages. " - James Lovelock Based on slides for Building Java Programs by Reges/Stepp, found at http://faculty.washington.edu/stepp/book/ CS305j Introduction to Computing Nested For Loops Case Study

Drawing complex figures Write Java code to produce the following output. Write nested for loops to capture the repetition. Use a constant so that the size of the figure could be changed simply by modifying one line of your program. #*********# | ******* | | ***** | | *** | | * | (it's supposed to look like an hourglass...) CS305j Introduction to Computing Nested For Loops Case Study

Nested For Loops Case Study Change Easily? How easy is it to change program to produce this output? #*************# | *********** | | ********* | | ******* | | ***** | | *** | | * | CS305j Introduction to Computing Nested For Loops Case Study

Nested For Loops Case Study Pseudo-code pseudo-code: A written English description of an algorithm to solve a programming problem. Writing pseudo-code for a complicated program can help us get the main idea of how the problem should be solved, so that we can try to find a working algorithm. Example: Suppose we are trying to draw a box of stars on the screen which is 12 characters wide and 7 tall. A possible pseudo-code for this algorithm: draw 12 stars. for each of 5 (7-2) lines, draw a star. draw 10 (12-2) spaces. ************ * * CS305j Introduction to Computing Nested For Loops Case Study

Tables to examine output #*********# | ******* | | ***** | | *** | | * | line spaces stars 1 7 2 5 3 4 CS305j Introduction to Computing Nested For Loops Case Study