Notesc120Mar515.notebook. March 05, Next I want to change the logic to handle all four of these:

Similar documents
introjs.notebook March 02, 2014

c122mar413.notebook March 06, 2013

Decision Making in C

There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

Chapter 9 - JavaScript: Control Structures II

1/22/2017. Chapter 2. Functions and Control Structures. Calling Functions. Objectives. Defining Functions (continued) Defining Functions

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

Dynamism and Detection

Lecture 5 Tao Wang 1

Chapter 10 JavaScript/JScript: Control Structures II 289

Exercise 1: Basic HTML and JavaScript

8. Control statements

Basic PHP. Lecture 19. Robb T. Koether. Hampden-Sydney College. Mon, Feb 26, 2108

HTMLnotesS15.notebook. January 25, 2015

Programming in C++ PART 2

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Add Subtract Multiply Divide

Chapter 17. Fundamental Concepts Expressed in JavaScript

Computational Expression

COMS 469: Interactive Media II

Chapter 2: Functions and Control Structures

STATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration

Skill Area 306: Develop and Implement Computer Program

INFS 2150 Introduction to Web Development and e-commerce Technology. Programming with JavaScript

Objectives. Introduction to JavaScript. Introduction to JavaScript INFS Peter Y. Wu, RMU 1

CSC Web Programming. Introduction to JavaScript

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

Discrete Structures Lecture 14

5. Selection: If and Switch Controls

An Introduction to Programming with C++ Sixth Edition. Chapter 7 The Repetition Structure

Structured Program Development

Enterprise Content Management System Monitor 5.2

Title: Jan 29 11:03 AM (1 of 23) Note that I have now added color and some alignment to the middle and to the right on this example.

LECTURE 5 Control Structures Part 2

Command-driven, event-driven, and web-based software

Flow Control. CSC215 Lecture

LECTURE 04 MAKING DECISIONS

Following is the general form of a typical decision making structure found in most of the programming languages:

Introduction to Conditionals

Working with JavaScript

CS1150 Principles of Computer Science Boolean, Selection Statements

Basic Syntax - First Program 1

Computers and FORTRAN Language Fortran 95/2003. Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes. Topics:

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

M275 - Web Development using PHP and MySQL

Chapter 3, Selection. Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved.

Discussion 12 The MCE (solutions)

Working with Lists 4

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

Midterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can.

Honors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F

Lesson 7: If Statement and Comparison Operators

1D CIW JavaScript Fundamentals exam

Chapter 4: Making Decisions

Branches, Conditional Statements

Introduction. C provides two styles of flow control:

Lesson 6: Introduction to Functions

Chapter 4: Making Decisions

SELECTION. (Chapter 2)

REPETITION CONTROL STRUCTURE LOGO

Mobile Site Development

3 The Building Blocks: Data Types, Literals, and Variables

<form>. input elements. </form>

Program Design Phase. Algorithm Design - Mathematical. Algorithm Design - Sequence. Verify Algorithm Y = MX + B

CHAPTER : 9 FLOW OF CONTROL

What is Bash Shell Scripting?

Princess Nourah bint Abdulrahman University. Computer Sciences Department

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

BIL101E: Introduction to Computers and Information systems Lecture 8

Chapter 4: Making Decisions

Name Section: M/W T/TH Number Definition Matching (6 Points)

Microsoft Visual Basic 2005: Reloaded

What is PHP? [1] Figure 1 [1]

Boolean evaluation and if statements. Making decisions in programs

Lesson 5: Introduction to Content Matchers

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

PHP. Interactive Web Systems

CSC 337. JavaScript Object Notation (JSON) Rick Mercer

JavaScript Functions, Objects and Array

COMPUTER PROGRAMMING LOOPS

HTML5 and CSS3 More JavaScript Page 1

CGS 3066: Spring 2015 JavaScript Reference

c122jan2714.notebook January 27, 2014

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017)

Loops and Conditionals. HORT Lecture 11 Instructor: Kranthi Varala

Lecture 12. PHP. cp476 PHP

Chapter 3 Structured Program Development

C++ Programming Lecture 7 Control Structure I (Repetition) Part I

In this lab, you will learn more about selection statements. You will get familiar to

Basic PHP Lecture 17

1. Cascading Style Sheet and JavaScript

JavaScript Introduction

FIN- Purchase Order Requisition Procurement Services

People = End Users & Programmers. The Web Browser Application. Program Design Phase. Algorithm Design -Mathematical Y = MX + B

Transcription:

Next I want to change the logic to handle all four of these: Note after the else I have two curly braces and embedded inside them I ask the next question and deal with its yes and its no. 1

Flowchart of the logic using if..else. 2

This is the example you started to code at the end of class on Tuesday. 3

I defined a variable mypoints and could have used = 0 to give it an initial value. I could have made msg = ""; to make it contain nothing. I prompt the user for mypoints and then I determine which prize group they are in based on the points. Since I see a msg saying group A I know that I entered a number greater than 50. 4

5

Here I have window.prompt. The use of window is optional. It simply means a prompt in the window. You can use the concatenate + or the separator, between the things that you write. Instead of the separator after thestate, I could use the + to concatenate. Since I want the same thing if it is MA or RI then I can make this compound. Note the <br> within the quotes is part of the literal and therefore it gets sent to the browser which recognizes it as a tag and moves down to the next line. 6

I entered Jon for thename and MA for thestate. Since MA is one of the things I test for I write thename concatenated with you live in concatenated with thestate. Now I took the <br> out of the document.write statements and put in another document.write saying Done after the if has ended. Note that the result does not skip a line. If I had left the <br>, it would have skipped the line. 7

Now I put the <br> in before Done so it skips to the next lin. 8

On this one I put a seprate document.write for skipping down to the next line. 9

On this one I entered Ann for the prompt to enter thename and I entered a state other than MA or RI when prompted for thestate. Lets say I entered NY. That means thestate is not equal to MA or RI so I take the else and write thename concatenated with a message. Note that in the IF I have two complete conditions thestate == "MA" is one complete condition and thestate == "RI" is another complete condition. 10

One of the conditions (or both) was not true so I execute the else. This is an AND relationship which means both things have to be true. If either is false I execute the else. 11

We are looking at a while loop with a condition. The loop will continue as long as ct is less than or equal to the data_input I took in at the prompt. Note that I set ct to 1 prior to entering the loop. Inside I am changing the control which is ct. ct is the control These are the three things you need to successfully construct a loop 12

I entered 7. set the control test the control change the control The loop gets executed repeatedly until the condition that tests the control is no longer true. Note that to make this work it is necessary that inside the loop I change the control. Note it is possible not to enter the loop. If I set ct and data_input such that ct is not less than or equal to data_input when I test, I will not enter the loop. See next slide. 13

When I entered 0 for data_input, then ct which was set to 1 is not less then or equal to data_input so the loop is not entered and the line below is written. 14

Since the do does not check until after the loop has been executed once, you will always go through once see next slide. condition at the bottom with the while. 15

I entered 0 for data_input. ct is1 so it is not less then or equal to the 0 in data_input so the loop is not entered and the line after the loop is written. 16

The check happened after I executed. I entered a 0 for data_input. 17