Programming Basics using Real-life examples. Activities Recipe Assembly instructions for a toy Map out the plan at amusement park A busy day schedule.

Slides:



Advertisements
Similar presentations
4-3 Writing Functions Warm Up Lesson Presentation Lesson Quiz
Advertisements

Function Rules By: Christine Berg Edited By: V T Hamilton Edited By: V T Hamilton.
Welcome to the Webinar “Live” Review for Final Exam (MAC 1105)
Sl No Top-up Amount No Of Affiliate Ads Payment Per Day By Affiliate Ad Total Affiliate Ad Income 1.5,000/- Daily 2 ad for 100 days 100/- Affiliate.
Update(s) 2 nd month of coding! Exam1 – mostly good. Great improvements from the practice exam to the exam itself! Exam2 (week of March 4 th ) will be.
Programming Basics using Real-life examples Dr. Jeyakesavan Veerasamy CS faculty, UT Dallas, USA
Programming Methodology (1). public class Hello { public static void main(String[] args) { System.out.println("Hello world"); } } Hello world.
The Impact of Foreign Exchange Rates By Paul D. Mixon.
College of Information Technology & Design
Summer ’12 AP Computer Science APCS Summer Assignments Read thoroughly this ppt and solve examples 6 and 7.
What does it mean to say… “60% of the cars in the parking lot are blue”?
CS101: Introduction to Computer programming
Lesson Menu Five-Minute Check (over Lesson 5–7) Main Idea and Vocabulary Key Concept: Percent of Change Example 1:Real-World Example: Find Percent of Change.
Differences Between High School and College. Time Management in High School – You have a regular scheduled day from 8:10-3:35. Choosing Responsibly in.
Dr. Mike Bailey Department of Systems Engineering and Operations Research.
Lesson Menu Five-Minute Check (over Lesson 5–5) Main Idea and Vocabulary Example 1:Estimate Percents of Numbers Example 2:Estimate Percents of Numbers.
Setting Up Your Personal BIT115 Workspace ON A USB THUMB DRIVE OR YOUR LAPTOP.
ALGORITHMS AND FLOWCHARTS
Introduction to Programming using Java Dr. Jey Veerasamy July 31 st – August 23 rd 9:30 am to 12 noon 1.
Using Flowcharts. Sample Flowchart (without text) 2.
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
1 CENG 707 Data Structures and Algorithms Nihan Kesim Çiçekli Department of Computer Engineering Middle East Technical University Fall 2010.
Apprenticeship Learning by Inverse Reinforcement Learning Pieter Abbeel Andrew Y. Ng Stanford University.
Apprenticeship Learning by Inverse Reinforcement Learning Pieter Abbeel Andrew Y. Ng Stanford University.
Jan. 25, 2001CSci Clark University1 CSci 250 Software Design & Development Lecture #4 Thursday, Jan. 25, 2001.
Welcome to C++ Programming Workshop at The University of Texas at Dallas Presented by John Cole March 14-15, 2013.
Adapted from slides by Marie desJardins
February 17, 2015Applied Discrete Mathematics Week 3: Algorithms 1 Double Summations Table 2 in 4 th Edition: Section th Edition: Section th.
Computer Programming 12 Lesson 2 - Organizing the Problem By Dan Lunney.
PYTHON PROGRAMMING Week 10 – Wednesday. TERMS – CHAPTER 1 Write down definitions for these terms:  Computation  Computability  Computing  Artificial.
East Heights Elementary Henderson County Schools Reading for Succeeding.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
10 th Grade Budget 10 th Grade Budgeting and Financial Success #3.
BUSINESS MATHEMATICS & STATISTICS. LECTURE 45 Planning Production Levels: Linear Programming.
Chap 1-1 Chapter 1 Introduction and Data Collection Business Statistics.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 2 I Am Not a Control Freak!
Multiple Answer Questions. Multiple Answer Question Types Look for patterns in the answers Questions with two “sets” of answers – The answer is one from.
CS001 Introduction to Programming Day 2 Sujana Jyothi
Engineering 1020 Introduction to Programming Peter King Winter 2010.
WEIGHTED AVERAGE ALG114 Weighted Average: an average where every quantity is assigned a weight. Example: If a teacher thinks it’s more important, a final.
Introduction and Data Collection Basic Business Statistics 10 th Edition.
State the domain and range of each relation. Unit 3, Lesson 2 Mrs. King.
Unit 4: Normal Distributions Part 2 Statistics. Focus Points Given mean μ and standard deviation σ, convert raw data into z-scores Given mean μ and standard.
Power Point Created by: Suzanne Fitzgerald & Candice Styer
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
Graphs can help you see patterns in data. Steps to draw a graph: 1)Choose the scales and the intervals. 2)Draw the graph and plot the data. Estimate data.
CIS 115 AID Peer Educator/cis115aid.com FOR MORE CLASSES VISIT
CIS 115 Slingshot Academy / Tutorialrank.com Tutorialrank.com For More Tutorials
IT 210 Week 7 Chapter 5 Programming Problems To purchase this material link Programming-Problems.
AP CSP: Performance Task - Explore
What is this “Viterbi Decoding”
CIS 115 Possible Is Everything/snaptutorial.com
CIS 115 Lessons in Excellence-- cis115.com. CIS 115 All Exercises Devry University (Devry) For more course tutorials visit CIS 115 All.
CIS 115 Education for Service-- cis115.com. CIS 115 All Exercises Devry University (Devry) For more course tutorials visit CIS 115 All.
An Introduction to Control Structures
Algorithms & Pseudocode
Lesson 3. 1 How do we interpret and represent functions. Standards F
Introduction to Algorithms
FUNCTIONS X Y.
Weighted Interval Scheduling
Assignment 2: Due Week 11, Friday
What do all these things have in common?
An Introduction to Control Structures
Homing sequence: to identify the final state.
Equations and functions
Domain and Range.
KEY CLUB MEETING November 13TH, 2018
Weighted Interval Scheduling
CSSE463: Image Recognition Day 17
 Is a machine that is able to take information (input), do some work on (process), and to make new information (output) COMPUTER.
Presentation transcript:

Programming Basics using Real-life examples

Activities Recipe Assembly instructions for a toy Map out the plan at amusement park A busy day schedule What is the common idea for all these activities?

Programming problem: Using sequence structure Compute the weighted score based on individual assignments’ scores. Let us say there are only 3 assignments & 2 exams, each with max score of 100. Respective weights are (10%, 10%, 10%, 35% and 35%) Sample input & output: Input: Output: 96.5%

Pseudocode Prompt & get the score for assignment1 Prompt & get the score for assignment2 Prompt & get the score for assignment3 Prompt & get the score for exam1 Prompt & get the score for exam2 weightedScore = (assignment1 + assignment2 + assignment3) * (exam1 + exam2) *.35 output weightedScore

Activities Drive car or take DART bus? Party or study? Fly or drive? What is the common idea for all these activities?

Programming problem: using decision structure Get hourly pay rate & # of hours, compute the weekly pay, but do not pay for hours beyond 50. Sample inputs: Input: Pay Rate Input: Hours Output 15030Rs Rs. 7500

Pseudocode Prompt & get hourly pay rate & # of hours IF hours <= 50 pay = hours * payRate; ELSE pay = 50 * payRate; ENDIF output pay

C code Prompt & get hourly pay rate & # of hours if (hours <= 50) pay = hours * payRate; else pay = 50 * payRate; output pay

Programming problem: using decision structure V2: Get hourly pay rate & # of hours, compute the weekly pay, but do not pay for >50 hours. Also, pay 1.5 times regular pay for overtime hours (that is, # of hours beyond regular 40 hours). First 40 hours: payRate Next 10 hours: payRate * 1.5 Beyond 50 hours: 0

pseudocode IF hours <= 40 pay = payRate * hours; ELSE IF hours <= 50 pay = payRate * 40 + payRate * 1.5 * (hours – 40); ELSE pay = payRate * 40 + payRate * 1.5 * 10;

pseudocode #2 overHours = hours – 40; IF hours <= 40 pay = payRate * hours; ELSE IF hours <= 50 pay = payRate * 40 + payRate * 1.5 * overHours; ELSE pay = payRate * 40 + payRate * 1.5 * 10;

pseudocode #3 hours = (hours > 50 ? 50 : hours); IF hours <= 40 pay = payRate * hours; ELSE pay = payRate * 40 + payRate * 1.5 * (hours – 40);

pseudocode #4 hours = (hours > 50 ? 50 : hours); IF hours <= 40 pay = payRate * hours; ELSE basePay = payRate * 40; overPay = payRate * 1.5 * (hours – 40); pay = basePay + overPay;

Activities Bring in tons of purchased items from car to house Load up uhaul truck when cleaning up apartment Eat cookies from a box Taking an exam that has several questions What is the common idea for all these activities?

Programming problem: Using repetition structure Compute the average score for the whole class.

Are we ready to code it?

Guessing game Guess a number between 1 and 100 in your mind. Write a program so that the computer will ask you a series of questions and determine that number based on your answers. Repeat the following steps as many times as needed: Computer asks, “Is it NN?” User responds with

Range – 2 variables: low = 1 and high = 100 compute mid = (low + high) / 2 Ask the user: Is it mid? Get user response adjust low or high based on response repeat as needed Pseudocode

Detailed pseudocode Initialize range – 2 variables: low = 1 and high = 100 do { compute mid = (low + high) / 2 Ask the user: Is it mid? Get user response if (response == ‘<‘) high = mid-1; else if (response == ‘>’) low = mid+1; while (response != ‘=‘);

Are we ready to code it?

Google for “Java random number generation”

Guessing game V2 – Role reversal Let the computer guess a number between 1 and 100. Write a program so that the computer will answer a series of your questions and you will determine the number based on computer’s responses.

Pseudocode Generate a random number between 0 and 100: assign rand() % 101 to a variable. then enter the loop – get a guess from the user – output, or = repeat until user enters =

Are we ready to code it? How to make the computer guess a number?

Summary All programs have only 3 control structures: Sequence, decision & repetition Problem description  High level idea  Detailed Pseudocode  Implement in specific language  Executable program

C++ strings Similar functionality to hangman game Write a method to return # of tries to guess all the letters in a given word. Sample run: Guess the letters in *******: s letters in s******:

Pseudocode for guessWord() bool guessed[100];  initialize to false using loop int exposedCount = 0; int len = word.length(); for(int i = 0; i < len ; i++) guessed[i] = false; do { for(int i = 0; i < len ; i++) cout << (guessed[i] ? word[i] : “*”); include code for getting next guess from the user and updating guessed[] array and exposedCount. } while (exposedCount < len);