Input, Process, Output

Similar documents
Visual Logic Instructions and Assignments

Scanner sc = new Scanner(System.in); // scanner for the keyboard. Scanner sc = new Scanner(System.in); // scanner for the keyboard

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Chapter 2: Elements of Java

Chapter 2 Elementary Programming

Introduction to Python

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

1st Grade Math Standard I Rubric. Number Sense. Score 4 Students show proficiency with numbers beyond 100.

2. Capitalize initial keyword In the example above, READ and WRITE are in caps. There are just a few keywords we will use:

Java Basics: Data Types, Variables, and Loops

Introduction to Java

Chapter One Introduction to Programming

Computer Science 217

PAYCHEX, INC. BASIC BUSINESS MATH TRAINING MODULE

Everyday Mathematics CCSS EDITION CCSS EDITION. Content Strand: Number and Numeration

Everyday Mathematics GOALS

JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

Writing Simple Programs

CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March Overview/Questions

What's New in ADP Reporting?

The Properties of Signed Numbers Section 1.2 The Commutative Properties If a and b are any numbers,

Mr. Anker Tests Current Listing of Activities, December 2008

VB.NET Programming Fundamentals

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Number Representation

AP Computer Science Static Methods, Strings, User Input

Computer Programming I & II*

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

Prentice Hall: Middle School Math, Course Correlated to: New York Mathematics Learning Standards (Intermediate)

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June Dr.-Ing.

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Minnesota Academic Standards

Sources: On the Web: Slides will be available on:

SOME EXCEL FORMULAS AND FUNCTIONS

C++ Language Tutorial

Introduction to Visual C++.NET Programming. Using.NET Environment

SAT Math Facts & Formulas Review Quiz

Excel: Introduction to Formulas

Welcome to Basic Math Skills!

The symbols indicate where the topic is first introduced or specifically addressed.

Possible Stage Two Mathematics Test Topics

BA II Plus. Guidebook. Texas Instruments Instructional Communications. Dave Caldwell David Santucci Gary Von Berg

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

Chapter 3. Input and output. 3.1 The System class

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Maple Introductory Programming Guide

Multiplying and Dividing Fractions

CSE140: Midterm 1 Solution and Rubric

BANK B-I-N-G-O. service charge. credit card. pen. line nickel interest cash bank. ATM dollar check signature. debit card.

Chapter 1 An Introduction to Computers and Problem Solving

Welcome to Harcourt Mega Math: The Number Games

Introduction to Java. CS 3: Computer Programming in Java

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Verbal Phrases to Algebraic Expressions

ExamView Dynamic Questions Training Guide for PC and Mac Users

MATH-0910 Review Concepts (Haugen)

Parts and Wholes. In a tangram. 2 small triangles (S) cover a medium triangle (M) 2 small triangles (S) cover a square (SQ)

MATLAB Programming. Problem 1: Sequential

Introduction to Python

Scope and Sequence KA KB 1A 1B 2A 2B 3A 3B 4A 4B 5A 5B 6A 6B

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

ALGORITHMS AND FLOWCHARTS. By Miss Reham Tufail

ALGORITHMS AND FLOWCHARTS

Mathematics Scope and Sequence, K-8

Factoring Polynomials

IV-1Working with Commands

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Progressing toward the standard

Programming and Software Development CTAG Alignments

numerical place value additional topics rounding off numbers power of numbers negative numbers addition with materials fundamentals

Final Exam Review: VBA

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005

How do you compare numbers? On a number line, larger numbers are to the right and smaller numbers are to the left.

To Evaluate an Algebraic Expression

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

Grade 6 Mathematics Performance Level Descriptors

MAFS: Mathematics Standards GRADE: K

Quick Reference ebook

Everyday Math Online Games (Grades 1 to 3)

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

Glencoe. correlated to SOUTH CAROLINA MATH CURRICULUM STANDARDS GRADE 6 3-3, , , 4-9

Tennessee Mathematics Standards Implementation. Grade Six Mathematics. Standard 1 Mathematical Processes

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: b + 90c = c + 10b

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Microsoft Access 3: Understanding and Creating Queries

MICROSOFT EXCEL FORMULAS

Some Scanner Class Methods

Creating Basic Excel Formulas

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Chapter 2 Writing Simple Programs

C PROGRAMMING FOR MATHEMATICAL COMPUTING

1 st Grade Math Do-Anytime Activities

Marks-to-Market in U.S. Treasury Futures and Options: Conventions for Computing Variation Margin Amounts

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016

Florida Math Correlation of the ALEKS course Florida Math 0018 to the Florida Mathematics Competencies - Lower

Solve addition and subtraction word problems, and add and subtract within 10, e.g., by using objects or drawings to represent the problem.

Recall the process used for adding decimal numbers. 1. Place the numbers to be added in vertical format, aligning the decimal points.

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Transcription:

Input, Process, Output Chapter 1 1

Introduction A computer program is a solution to a problem Most useful computer programs do at least 3 things: Input input data process data output resulting information Process 2 Output

Internet Shopping Cart System INPUT PROCESS OUTPUT Customer ID Mailing address Credit card number Product I Connect to Database Determine product cost Calculate sales tax Bill customer Print customer receipt Generate shipping label Generate report for sales dept. 3

Logic and Syntax 4 An algorithm is the blueprint for a computer program/ software Tools for representing algorithms Flowcharts Pseudocode Visual Logic is a visual tool combining graphics of flowcharts and pseudocode-like syntax Visual Logic animates or executes the algorithm Visual Logic IS NOT a computer programming language Once an algorithm is developed it must be coded in a programming language to be used as a computer program

Simple Programming Formats An output statement displays information (in a window/ console/file) An input statement accepts data from the user and stores that data into a variable A variable is a storage location in computer memory that can be accessed and changed in the program 5

Simple Programming Formats (contd) A variable has a name (which does not change) and an associate data value (which may change during the execution) e.g. NAME is the name of a variable and its data value is the string Dave The name of a variable is also called an identifier. An identifier cannot have any spaces in it, only letters, numbers and underscore (_) Legal identifiers: NAME, num1, interestrate, Num_1, Num_2 Visual Logic is case insensitive 6

Hello Name Program The input string value MUST be entered inside quotes ( ) 7 But the output string is not displayed with quotes ( )

Input Statement Summary Input statements are used to get data into variables In Visual Logic, the input flowchart element is a parallelogram with the keyword Input following by the variable name (e.g. Input: NAME) When the input statement is executed the user is prompted to enter a value using the keyboard. The value typed is then stored in the variable for later use. String input must be placed inside quotes Numeric input must contain only digits and possibly one decimal point. Percent symbols (%), dollar signs ($) and commas (,) or any other symbols are not allowed. 8

Partial weekly paycheck solution 9 What s this?

Assignment Statement Assignment statements are used to perform calculations and store the result An assignment statement is a processing step, so its flowchart shape is a rectangle An assignment statement contains a variable on the left-hand side (LHS), an expression on the right-hand side (RHS) and an equal sign (=) in the middle When an assignment statement is executed, the RHS expression is evaluated first. This value is stored in the variable (e.g. The result of the RHS becomes the data value of the variable on the LHS) Variables hold values and have a name variables are named memory locations 10

Weekly paycheck (partial solution) 11 Pay will have the value:?? 2030 Do you see the output?

Weekly paycheck (no formatting) 12

Weekly Paycheck (complete solution) FormatCurrency is an intrinsic function that formats the variable within the parentheses with a $, a decimal point and 2 places after the decimal 13 Note: the shape of Output is different than Input in Visual Logic

Weekly paycheck (no formatting) What would you see if you used FormatCurrency? 14

Weekly paycheck (formatting) FormatCurrency rounds off to 2 decimal places 15

Arithmetic Expressions 4 5 + 2 1 + 3*7 5 2 +2*8 12/4*2 12/5+3 Order of Operations: PEMDAS Parentheses Exponents Multiplication (*) &Division (/) (from left to right) Addition (+) & Subtraction (-) (from left to right) 16

Operators in Visual Logic OPERATOR SYMBOL EXAMPLE 1. Exponentiation ^ 2^3 = 8 2. Multiplication and Division *, / 2*3=6, 5/2=2.5 3. Integer Division \ 5\2 = 2, 38\10= 3 4. Integer Remainder Mod 5 Mod 2 = 1 5. Addition and Subtraction +, - 2+15=17 Examples: New Operators only with Integers (whole numbers) Integer Division: 12\4 à 3, 17 \3 à 5 Integer Remainder: 12 Mod 4 à 0, 17 Mod 3 à 2 17

Quick Check 1-1, 1-B Pg 12 1-A: A=3, B=5 1. A+B*5 = 40 or 28? 2. (2*3)^2 = 3. 11\ A = 4. 2*3^2 = 5. 11 / A = 6. 11 Mod A = 1-B: 1. (Exam 1 + Exam 2 + Exam 3)/3 2. 1 + 1 /2 + 1/4 3. (4*A^2*B)/C (do you need the parentheses in 3.) 18

Example: Average Demo in Visual Logic Step Into 19

Examples Odd or Even? Problem: Given a whole number, N, determine if it is ODD or EVEN? Algorithm: If N Mod 2 equals 0 è N is even Otherwise è N is odd 20

Examples Coins Change Problem: Given a whole number, N < 100, determine how many quarters, dimes, nickels, pennies make up N cents with the least # of coins. Example: N = 92 # of Quarters = 3 # of Dimes = 1 # of Nickels = 1 # of Pennies = 2 92 / 25 = 3.68 92\25 = 3 ç # of Q 92 Mod 25 = 17 ç remainder or left over (92 3*25 = 92 75 = 17 == 92 Mod 25 17 \10 = 1 ç # of D 17 Mod 10 = 7 ç left over 21

22

23

Example Result Intrinsic Functions in VL FormatCurrency(12345) $12, 345.00 FormatCurrency(.02) $0.02 FormatPercent(0.0625) 6.25% FormatPercent(0.75) 75.00% Abs(-3.3) 3.3 Abs(5.67) 5.67 Int(3.8) 3 Int(7.1) 7 Round(3.8) 4 Round(7.1) 7 Random(5) A random integer between 0 and 4 Random (6) + 1 A random integer between 1 and 6 24

Table 1-1: Correct Programming Formats Value Written Format Programming Format Comment String Hello World Hello World Use quotes to delimit strings Percent 15% 0.15 Use decimal format Dollars $300 300 Dollar signs not allowed Large Numbers 12,345,678 12345678 Commas not allowed 25

Output Statement Summary Output statements are used to display information In Visual Logic, the output flowchart element is a parallelogram with the keyword Output followed by an output expression When executed, string literals (e.g. Dave or Quarters ) are displayed exactly as typed inside the containing quotes When executed, expressions are evaluated and the result is displayed The ampersand (&) operator maybe used to concatenate a series of string literals, variables and expressions into one large expression Carriage returns in the output expression appear as carriage returns in the displayed output 26