UMBC CMSC 104 – Section 01, Fall 2016

Slides:



Advertisements
Similar presentations
CMSC 104, Version 9/011 Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class Project Incremental.
Advertisements

1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Do now: These cuboids are all made from 1 cm cubes
Algorithms IV: Top-Down Design
Perimeter Is the sum of the lengths of the sides. When solving a perimeter problem, it is helpful to draw and label a figure to model the region.
ALGORITHMS AND FLOWCHARTS
CMSC 104, Version 9/01 1 The Box Problem: Write an interactive program to compute and display the volume and surface area of a box. The program must also.
PYTHON PROGRAMMING Week 10 – Wednesday. TERMS – CHAPTER 1 Write down definitions for these terms:  Computation  Computability  Computing  Artificial.
Pseudocode algorithms using sequence, selection and repetition
Surface Area and Volume
CMSC 104, Section 301, Fall Lecture 06, 9/18/02 Algorithms, Part 3 of 3 Topics Disk Quota Exceeded. Using Pine. More Algorithms Reading Read.
Lesson 11-7 Similar Solids. Two solids of the same type with equal ratios of corresponding linear measures are called similar solids.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
CMSC 104, Version 9/01 1 Functions, Part 3 of 3 Topics: Coding Practice o In-Class Project: The Box o In-Class Project: Drawing a Rectangle Reading: None.
CSC 111. Solving Problems with Computers Java Programming: From Problem Analysis to Program Design, Third Edition3 Solving Problems Stages 1.Problem.
1 Algorithms Practice Topics In-Class Project: Tip Calculator In-Class Project: Drawing a Rectangle.
CMSC 104, Version 8/061L10ArithmeticOps.ppt Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class.
Warm-Up #1 11/30 1. Write down these 3 formulas:
Algorithms, Part 3 of 3 Topics In-Class Project: The Box
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
CMSC 104, Version 8/061L05Algorithms2.ppt Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode Control Structures Reading Section 3.1.
Program design Program Design Process has 2 phases:
ALGORITHMS AND FLOWCHARTS
GC101 Introduction to computers and programs
Software Development Expansion of topics page 28 in Zelle
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
Algorithms and Flowcharts
Chapter 5: Control Structure
Teaching design techniques to design efficient solutions to problems
Introduction To Flowcharting
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
UMBC CMSC 104 – Section 01, Fall 2016
Algorithm and Ambiguity
2008/09/24: Lecture 6b CMSC 104, Section 0101 John Y. Park
ALGORITHMS AND FLOWCHARTS
Repetition Chapter 6 12/06/16 & 12/07/16 1 1
The while Looping Structure
ALGORITHMS AND FLOWCHARTS
2008/11/12: Lab 5/Lecture 17 CMSC 104, Section 0101 John Y. Park
Pseudocode algorithms using sequence, selection and repetition
2008/09/22: Lecture 5 CMSC 104, Section 0101 John Y. Park
1) C program development 2) Selection structure
ALGORITHMS AND FLOWCHARTS
The while Looping Structure
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithm and Ambiguity
Chapter 5: Control Structure
Algorithms, Part 3 of 3 Topics In-Class Project: The Box
Solutions to In-Class Problems
Algorithms Practice Topics In-Class Project: Tip Calculator
Functions, Part 4 of 4 Topics: Coding Practice Reading: None
CHAPTER 4 Iterative Structure.
Introduction to Programming
Section 5.8 Solving Equations by Factoring
Similar Shapes.
Functions, Part 3 of 3 Topics: Coding Practice Reading: None
The while Looping Structure
Mod 28 F.
Mod 38 F.
Algorithms, Part 3 of 3 Topics In-Class Project: Tip Calculator
Functions, Part 3 of 4 Topics: Coding Practice Reading: None
Area of combined shapes
CHAPTER 6 Testing and Debugging.
Module 4 Loops and Repetition 9/19/2019 CSE 1321 Module 4.
Presentation transcript:

UMBC CMSC 104 – Section 01, Fall 2016 Algorithms III

Notes & Announcements Project 2 due… now! Project 3 posted tonight Due next Thursday 10/13 at 5:30 PM

Writing Algorithms from Scratch Given a problem statement, we are going to write the corresponding generic algorithm for the solution. We will use the following procedure: Determine the algorithm inputs and outputs Pseudocode a rough algorithm Complete the pseudocode

The Cube Problem: Write an interactive program to compute and display the volume and surface area of a cube. The program must also display the cube dimensions. Error checking should be done to be sure that all cube dimensions are greater than zero.

The Cube: What Do We Know? We’re working with a cube. Cubes have equal length sides. Lets call our side length x. We need to calculate surface area of the cube. Cubes have 6 sides. 6x2 We need to calculate the volume of the cube. x3 We need to display the cube dimensions We need to verify that all dimensions are greater than zero

The Cube: Inputs & Outputs Side length Outputs Dimensions Surface Area Volume

The Cube: Rough Pseudocode Display “Enter the side length” Read <length> <surface area> = 6 * <length> * <length> <volume> = <length> * <length> * <length> Display “The dimensions are <length> x <length> x <length>” Display “The surface area is <surface area>” Display “The volume is <volume>”

The Cube: What are we missing? We’ve met all of our requirements, except ensuring all side lengths are greater than zero. How might we do this?

Control Structures Any problem can be solved using only three logical control structures: Sequence Selection Repetition

The Cube: Final Pseudocode Display “Enter the side length” Read <length> If (<length> is less than 1) Display “Invalid length! I quit!” Else <surface area> = 6 * <length> * <length> <volume> = <length> * <length> * <length> Display “The dimensions are <length> x <length> x <length>” Display “The surface area is <surface area>” Display “The volume is <volume>” End_If

The Cube: Final Pseudocode Display “Enter the side length” Read <length> While (<length> is less than 1) Display “Invalid length! Try again!” End_While <surface area> = 6 * <length> * <length> <volume> = <length> * <length> * <length> Display “The dimensions are <length> x <length> x <length>” Display “The surface area is <surface area>” Display “The volume is <volume>”

Drawing a Rectangle Problem: Write an interactive program that will draw a solid rectangle of asterisks (*). The program begins by prompting for dimensions. Error checking must be done to be sure that the dimensions are greater than zero.

A Solution… Display “Enter length” Read <length> Display “Enter width” Read <width> <length count> = 0 <width count> = 0 While (<length count> < <length>) While (<width count> < <width>) Display “*” <width count> = <width count> + 1 End_While Display Newline <length count> = <length count> + 1

Questions?