Homework 6 Due ( MT sections ) ( WTh sections ) about midnight Sun., 10/12 Mon., 10/13 Problems

Slides:



Advertisements
Similar presentations
This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Advertisements

CS107 Introduction to Computer Science Lecture 2.
CS110 Programming Language I Lab 10: Arrays I Computer Science Department Spring 2014.
Two examples of Problem Solving in Programming H. Chad Lane University of Pittsburgh CS7: Introduction to Programming.
Homework 14 Due ( MT sections ) ( WTh sections ) at midnight Sun., 12/7 Mon., 12/8 Problems
10-Jun-15 Just Enough Java. Variables A variable is a “box” that holds data Every variable has a name Examples: name, age, address, isMarried Variables.
Loops – While Loop Repetition Statements While Reading for this Lecture, L&L, 5.5.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Introduction to Computer Programming Looping Around Loops I: Counting Loops.
COMP 110 Classes Tabitha Peck M.S. February 20, 2008 MWF 3-3:50 pm Philips
University of British Columbia CPSC 111, Intro to Computation 2009W2: Jan-Apr 2010 Tamara Munzner 1 Loops III Lecture 19, Wed Mar
Homework 4 Due ( MT sections ) ( WTh sections ) at midnight Sun., 9/29 Mon., 9/30 Problems
TA: Nouf Al-Harbi NoufNaief.net :::
1 Scanning Tokens. 2 Tokens When a Scanner reads input, it separates it into “tokens”  … at least when using methods like nextInt()  nextInt() takes.
Programming Part 1 Armond R. Smith Zhenying Wu. Overview of this Class ● Transition from FTC -> FRC ● Using Your Resources ● Java Keywords o Data Types.
CS161 Topic #14 1 Today in CS161 Lecture #14 Practicing! Writing Programs to Practice Write a program that counts the number of vowels in a sentence, ended.
Welcome to CompSci 100! As You Arrive… Make sure you grab a syllabus packet. Read through it. I will be covering the most essential points in my talk,
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
CPS 2231 Computer Organization and Programming Instructor: Tian (Tina) Tian.
Chapter 6: Iteration Part 2. Create triangle pattern [] [][] [][][] [][][][] Loop through rows for (int i = 1; i
Nelson Series Talk Wed, 10/13 7:00 pm HMC’s Galileo Auditorium On Robots, Probability, and Artificial Intelligence This talk will expose the audience to.
CSc2310 tutoring session, week 8 Fall, 2012 Haidong Xue 5:30pm—8:30pm 10/23/2012 and 10/24/2012 -Using Exceptions -Homework 4.
Homework 11 Due ( MT sections ) ( WTh sections ) at midnight Sun., 11/14 Mon., 11/15 Problems
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
EXAM 1 REVIEW. days until the AP Computer Science test.
Homework 3 Due ( MT sections ) ( WTh sections ) at midnight Sun., 9/21 Mon., 9/22 Problems
This week in CS 5 HW 9 (2 problems) M/T sections W/Th sections due Sunday, 11/4 at midnight due Monday, 11/5 at midnight Recitation for HW9 -- Friday 11/2.
Homework 5 Due ( MT sections ) ( WTh sections ) at midnight Sun., 10/6 Mon., 10/7 Problems
C# Programming Fundamentals Control Flow Jim Warren, COMPSCI 280 S Enterprise Software Development.
Lecture 3 Decisions (Conditionals). One of the essential features of computer programs is their ability to make decisions. Like a train that changes tracks.
Homework 9 Due ( M & T sections ) ( W & Th sections ) at midnight Sun., 11/3 Mon., 11/4 Problems
CS 112 Introduction to Programming Arrays; Loop Patterns (break) Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone:
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 5.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
Chapter 5: Control Structures II J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design,
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Loops and Input COMP 102 #
Homework 8 Due ( MT sections ) ( WTh sections ) at midnight Sun., 10/28 Mon., 10/29 Problems Reading is under week 7, however.
Formatted Output (printf) CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Loops and Input COMP 102 #
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
Code Compression the benefits of looping... Today in CS 5 HW 4 - (3 problems) M/T sections W/Th sections due Sunday, 9/26 at midnight due Monday, 9/27.
Ionut Trestian Northwestern University
Written by: Dr. JJ Shepherd
THINKING PROCEDURALLY OR CONCURRENT (SIMULTANEOUSLY OR SIDE BY SIDE OR IN LOGICAL ORDER A- IDENTIFY THE COMPONENTS OF A PROBLEM B-IDENTIFY THE COMPONENTS.
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS 1 Copyright: 2015 Illinois Institute of Technology_ George Koutsogiannakis.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
Introduction to programming in java Lecture 22 Arrays – Part 2 and Assignment No. 3.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Homework 10 Due ( MT sections ) ( WTh sections ) at midnight Sun., 11/10 Mon., 11/11 Problems
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
Information and Computer Sciences University of Hawaii, Manoa
CS0007: Introduction to Computer Programming
CS1020 – Data Structures And Algorithms 1 AY Semester 2
using System; namespace Demo01 { class Program
CS305J Introduction to Computing
Chapter 5: Control Structures II
Repetition.
Homework 2 Sun., 9/12 Due Mon., 9/13 Problems available on-line
Truth tables: Ways to organize results of Boolean expressions.
Ionut Trestian Northwestern University
Truth tables: Ways to organize results of Boolean expressions.
class PrintOnetoTen { public static void main(String args[]) {
Chapter 2 Programming Basics.
Northwestern University
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
CSCI 203: Introduction to Computer Science I
Presentation transcript:

Homework 6 Due ( MT sections ) ( WTh sections ) about midnight Sun., 10/12 Mon., 10/13 Problems CS 5 website me at Submission problems? Grading concerns ? let me know!

Tutors available -- contact information

Tutors available -- lab places and times You may also seek out tutors away from the labs, by phone, in the dorms, etc. Available in the LAC Lab (Linde Activities Center) Available in Parsons PC Labs (the CIS classrooms)

HW 6 Problem 2: throwing darts at pi You’ll need to write (and use) the method: Problem 1: The Mudder’s Meander public static boolean throwAndCheckDart() Problem 3: Flesch readability score You’ll need to write (and use) 2 methods: public static int numSyllables(String word) public static boolean isVowel(char c) (0.5,0.5) (0.5) 1.0

Problem: to determine the readability of text Computers evaluating reading? The cow is of the bovine ilk. One end is moo the other milk ! *(syllables/word) *(words/sentence) very readable 14 words (don’t count the punctuation marks!) 2 sentences (do count the punctuation marks!) 16 syllables ( “bovine” and “other” are the two-syllable words) *(16/14) *(14/2) watch out! ~ 103

Handling input The cow is of the bovine ilk. One end is moo the other milk ! END H.nw() handles all whitespace as word separators. Newlines are not different than spaces. the text will end with the word “END” (and it will appear nowhere else!) punctuation will ALWAYS be separated from text while (true) { String w = H.nw(); if (w.equals(“END”)) break; // do all processing here } codeuser input H.nw() will return each space- separated String as a word. counting words, sentences?

main public static void main(String[] args) { while (true) { String w = H.nw(); if (w.equals(“END”)) break; }

// get each word in turn - using nextWord() // stop when END is seen // Stage 1: simply count up the # of Strings and print out the the end

// distinguish REAL words from “.” “!” “?” // Stage 2: count up the # of words + sents. print out both the end

// count the syllables of each word // Stage 3: take in SINGLE words and print the number of syllables in each

Syllables What’s a syllable ? Basically, a syllable is a cluster of 1 or more vowels in a word. emergevowelthe aeiouyAEIOUY Put another way, a syllable is any vowel that starts a word, plus any vowel that follows a consonant except a lone e at the end of the word But above all, every word must count as at least 1 syllable!

Helpful Methods public static int numSyllables(String word) simile Wrapped bungee Yes beautifully Sequoia What are some (other) English words for which this syllable algorithm is incorrect?

Checking for vowels public static boolean isVowel(char c) How would this get used to check for a vowel? How would this get used to check for a consonant?

Counting Syllables public static int numSyllables(String word)

Visualize: Easy as 

0. The user specifies how many darts to throw. // get numDarts from user // use a for loop to throw that many darts // keep track of how many hits we get // after all the darts, estimate 

1. The user specifies how accurately to estimate pi. // get tolerance from user // start throwing darts // keep track of # of hits and # of darts! // estimate  each time // continue while we are OUTSIDE the tol.

public static void main(String[] args) { H.pl(“How many steps?”); int W = H.ni(); // get width (W) from the user int p = 0; // the student’s initial position is 0 while ( Math.abs(p) < W ) { p = p + (int)(3*Math.random())-1; // update position printPosition(p,W); // print one line } The Mudd Meander… public static void printPosition(int p, int W) { }