Homework 5 Due ( MT sections ) ( WTh sections ) at midnight Sun., 10/6 Mon., 10/7 Problems

Slides:



Advertisements
Similar presentations
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
Advertisements

Computer Programming Lab(7).
Graohics CSC 171 FALL 2001 LECTURE 16. History: COBOL Conference on Data System Languages (CODASYL) - led by Joe Wegstein of NBS developed the.
CS110 Programming Language I
Homework 6 Due ( MT sections ) ( WTh sections ) about midnight Sun., 10/12 Mon., 10/13 Problems
Hand Crafting your own program By Eric Davis for CS103.
Homework 14 Due ( MT sections ) ( WTh sections ) at midnight Sun., 12/7 Mon., 12/8 Problems
Introduction to Computer Programming Stringing Along – Using Character and String Data.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Variables, Data Types, & Arithmetic Expressions CSC 1401: Introduction to Programming with Java Lecture 3 Wanda M. Kunkle.
Introduction to Computers and Programming Strings Professor: Evan Korth New York University.
Homework 4 Due ( MT sections ) ( WTh sections ) at midnight Sun., 9/29 Mon., 9/30 Problems
CS 180 Recitation 8 / {30, 31} / Announcements Project 1 is out –Due 10:00pm –Start early! –Use the newsgroup for your questions –LWSN B146.
MSc IT Programming Methodology (2). MODULE TEAM Dr Aaron Kans Dr Sin Wee Lee.
1 BUILDING JAVA PROGRAMS CHAPTER 3 THE SCANNER CLASS AND USER INPUT.
CS 241 – Computer Programming II Lab Kalpa Gunaratna –
CS1101: Programming Methodology Aaron Tan.
CPS 2231 Computer Organization and Programming Instructor: Tian (Tina) Tian.
CS1101: Programming Methodology Aaron Tan.
CS1101: Programming Methodology
CS 5 HW 12 (2 problems) M/T sections W/Th sections due Sunday, 11/21 at midnight due Monday, 11/22 at midnight Recitation for HW12 -- Friday 8:00am Looking.
1 Methods Instructor: Mainak Chaudhuri
CS107 Introduction to Computer Science Java Basics.
Computer Security coursework 2 Dr Alexei Vernitski.
Recursion A method is recursive if it makes a call to itself. A method is recursive if it makes a call to itself. For example: For example: public void.
Homework 11 Due ( MT sections ) ( WTh sections ) at midnight Sun., 11/14 Mon., 11/15 Problems
CS61B L02 Using Objects (1)Garcia / Yelick Fall 2003 © UCB Kathy Yelick Handout for today: These lecture notes Computer Science 61B Lecture 2 – Using Objects.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 2/10/2010.
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.
1 CSC 110AA Introduction to Computer Science for Majors - Spring 2003 Class 5 Chapter 2 Type Casting, Characters, and Arithmetic Operators.
Homework 9 Due ( M & T sections ) ( W & Th sections ) at midnight Sun., 11/3 Mon., 11/4 Problems
CS 1150 – Lab #3 – Representing Numbers TA – Sanjaya Wijeratne – Web Page -
CSC1401 Strings (text). Learning Goals Working with Strings as a data type (a class) Input and output of Strings String operations.
1 CS 177 Week 3 Recitation Slides Basic Math Operations, Booleans, and Character Operations.
Characters and Strings. Characters  New primitive char  char letter; letter = ‘a’; char letter2 = ‘C’;  Because computers can only represent numbers,
String and Scanner CS 21a: Introduction to Computing I First Semester,
CS110 Programming Language I Lab 4: Control Statements I Computer Science Department Spring 2014.
Homework 8 Due ( MT sections ) ( WTh sections ) at midnight Sun., 10/28 Mon., 10/29 Problems Reading is under week 7, however.
Homework #4: Operator Overloading and Strings By J. H. Wang Apr. 17, 2009.
BHCSI Programming Contests. Three contests Mock Contest #1  Friday, July 16 th  2:15 – 4:45pm UCF High School Online Contest  Thursday, July 22 nd.
Cryptography.
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.
Catie Welsh March 23,  Lab 6 due Friday by 1pm 2.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Strings CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Computer Programming 2 Lab (1) I.Fatimah Alzahrani.
Homework #3: Classes and Constructors By J. H. Wang Apr. 24, 2015.
Encryption. LEARNING OBJECTIVES: BY THE END OF THE LESSON YOU SHOULD KNOW. What encryption is and why it is important The basics of encryption techniques.
Substitution Ciphers Reference –Matt Bishop, Computer Security, Addison Wesley, 2003.
Information and Computer Security CPIS 312 Lab 1
Midterm 2 Review Notes on the CS 5 midterm Take-home exam due by 5:00 pm Sunday evening (11/14) Hand in your solutions under the door of my office, Olin.
Homework 10 Due ( MT sections ) ( WTh sections ) at midnight Sun., 11/10 Mon., 11/11 Problems
Copyright 2010 by Pearson Education Building Java Programs Chapter 4 Lecture 4-3: Strings, char reading: 3.3, 4.3.
REEM ALAMER REVISION FOR C LANGUAGE COURSE. OUTPUTS int main (void) { int C1, C2; int *p1, *p2; C1 = 8; p1 = &C1; C2 = *p1 / 2 + 5; p2 = &C2; printf ("C1.
Intelligent Data Systems Lab. Department of Computer Science & Engineering Practices 컴퓨터의 개념 및 실습 4 월 11 일.
Strings CSE 1310 – Introduction to Computers and Programming
Strings CSE 1310 – Introduction to Computers and Programming
Strings CSE 1310 – Introduction to Computers and Programming
Homework 12 Sun., 11/24 Due Mon., 11/25 Problems (2 of them)
Building Java Programs Chapter 4.3
Homework 2 Sun., 9/12 Due Mon., 9/13 Problems available on-line
Writing Methods.
Introduction to Java Programming
Encryption and Decryption
CS2011 Introduction to Programming I Methods (II)
class PrintOnetoTen { public static void main(String args[]) {
Recursion Method calling itself (circular definition)
More on iterations using
Information and Computer Security CPIS 312 Lab 3
Presentation transcript:

Homework 5 Due ( MT sections ) ( WTh sections ) at midnight Sun., 10/6 Mon., 10/7 Problems CS 5 website or Submission problems or other concerns?

Tutors available Academic Computing labs (Parsons) Linde Activities Center lab Friday Afternoons 1-4 pm Chris Hwang this week (10/4): Parsons Don Lee this week (10/4): Parsons Daniel Chan this week (10/4): LAC Lab Zach Andree this week (10/4): LAC Lab Annie Chang this week (10/4): LAC Lab Saturday Afternoons 1-4pm Chris Weisiger this week (10/5): Parsons Yu-Min Kim this week (10/5): Parsons Elizabeth Lee-Su this week (10/5): LAC Lab Aaron Homer this week (10/5): LAC Lab Sunday Afternoons 1-4pm Gabriel Neer this week (10/6): Parsons Jeff Brenion this week (10/6): LAC Lab Rene Logan this week (10/6): LAC Lab

Tutors available Sunday evenings 7-12pm Jenny Xu 6-9 this week (10/6): Parsons Eric Flynn 7-10 this week (10/6): Parsons Melissa Federowicz 7-10 this week (10/6): LAC Lab Max Yi 7-10 this week (10/6): LAC Lab Yu-Min Kim 9-12 this week (10/6): Parsons A. Klose 9-12 this week (10/6): Parsons Matt Beaumont-Gay 9-12 this week (10/6): LAC Lab Chris Hwang 9-12 this week (10/6): LAC Lab Monday Evenings 7-12pm Adam Kangas 7-10 this week (10/7): Parsons Ryka Neher 7-10 this week (10/7): Parsons Max Yi 7-10 this week (10/7): LAC Lab Annie Chang 9-12 this week (10/7): Parsons Paul Scott 9-12 this week (10/7): Parsons John McCollough 9-12 this week (10/7): Parsons Alex Pipkin 9-12 this week (10/7): LAC Lab Chris Wottawa 9-12 this week (10/7): LAC Lab Alex Utter 9-12 this week (10/7): LAC Lab

Problem 2 -- Caesar Cipher Encryption strategy Choose an amount to shift your message. Move each letter that amount. message: eorrgb lqvwuxfwlrqv zklfk uhwxuq wr sodjxh wkhlu lqyhqwru shift amount: 3 encrypted message:

bloody instructions which return to plague their inventor Macbeth, Act I, Scene 7 ???

Problem 2 -- Caesar Cipher Decryption strategy Shift the encrypted message by every possible shift amount Pick out the English text... eorrgb lqvwuxfwlrqv zklfk uhwxuq wr sodjxh wkhlu lqyhqwru encrypted message: all possible shifts: eorrgb lqvwuxfwlrqv zklfk uhwxuq wr sodjxh wkhlu lqyhqwru fpsshc mrwxvygxmsrw almgl vixyvr xs tpekyi xlimv mrzirxsv gqttid nsxywzhyntsx bmnhm wjyzws yt uqflzj ymjnw nsajsytw hruuje otyzxaizouty cnoin xkzaxt zu vrgmak znkox otbktzux isvvkf puzaybjapvuz dopjo ylabyu av wshnbl aolpy pucluavy jtwwlg qvabzckbqwva epqkp zmbczv bw xtiocm bpmqz qvdmvbwz kuxxmh rwbcadlcrxwb fqrlq ancdaw cx yujpdn cqnra rwenwcxa lvyyni sxcdbemdsyxc grsmr bodebx dy zvkqeo drosb sxfoxdyb mwzzoj tydecfnetzyd hstns cpefcy ez awlrfp esptc tygpyezc nxaapk uzefdgofuaze ituot dqfgdz fa bxmsgq ftqud uzhqzfad xhkkzu ejopnqypekjo sdeyd napqnj pk lhwcqa pdaen ejrajpkn yillav fkpqorzqflkp tefze obqrok ql mixdrb qebfo fksbkqlo zjmmbw glqrpsargmlq ufgaf pcrspl rm njyesc rfcgp gltclrmp aknncx hmrsqtbshnmr vghbg qdstqm sn okzftd sgdhq hmudmsnq bloody instructions which return to plague their inventor cmppez jotusvdujpot xijdi sfuvso up qmbhvf uifjs jowfoups dnqqfa kpuvtwevkqpu yjkej tgvwtp vq rnciwg vjgkt kpxgpvqt

Resources Suppose we have a method that shifts a character c by n letters. char advanceChar(char c, int n) Assume these work... length() (tells the length of a String ) charAt(int n) (returns the n th char of a String ) advanceChar(‘h’, 4) is advanceChar(‘z’, 2) is String s = “more java”; s.length() is s.charAt(2) is s.charAt( ) is ‘v’

High-level plan We have char advanceChar(char c, int n) length() (tells the length of a String ) charAt(int n) (returns the n th char in a String, starting at 0) What to do ?

advanceChar Now we need to worry about making this piece work... public static char advanceChar(char c, int n)

Working with char s _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { } ~ char c = ‘y’; c = (char)(c - 2); c += 5; How do we get back?

Style note // be sure to comment each method you write! public static char advanceChar(char c, int n) // Name: advanceChar // Inputs: a char (c) and an int (n) // Output: the char that is n places // to the right of c, where the // alphabet wraps from ‘z’ to ‘a’.

public static void main(String[] args) { int x = H.in.nextInt(); int y = H.in.nextInt(); int z = confusing(x,y); H.out.println(“z is ” + z); } public static int confusing(int y, int x) { int a = 0; a = 10*y + x; return a; } A message from our sponsor

Problem 1 -- finding e x Please input a power (a double) and I will raise e to that power: 2.5 Enter the number of terms you'd like to use (an int >= 1): 10 The result is Would you like to continue (yes/no)? no Inside main : This is e 2.5 computed using 10 terms of the series x0x0 0! x1x1 1! x2x2 2! x3x3 3! … 4 terms

public static double exp(double x, int numTerms) exp What does exp do? What are x and numTerms referring to?

power public static double power(double base, int p) What does power do? What are base and p referring to?

factorial public static double factorial(int n) What does factorial do? What is n referring to?

Problem 1 -- finding e x Please input a power (a double) and I will raise e to that power: 2.5 Enter the number of terms you'd like to use (an int >= 1): 10 The result is Would you like to continue (yes/no)? no Inside main :

This is e 2.5 computed using 10 terms of the series x0x0 0! x1x1 1! x2x2 2! x3x3 3! … 4 terms

Homework 5 Due ( MT sections ) ( WTh sections ) at midnight Sun., 10/6 Mon., 10/7 Problems CS 5 website or Submission problems or other concerns?

Tutors available Academic Computing labs (Parsons) Linde Activities Center lab Friday Afternoons 1-4 pm Chris Hwang this week (10/4): Parsons Don Lee this week (10/4): Parsons Daniel Chan this week (10/4): LAC Lab Zach Andree this week (10/4): LAC Lab Annie Chang this week (10/4): LAC Lab Saturday Afternoons 1-4pm Chris Weisiger this week (10/5): Parsons Yu-Min Kim this week (10/5): Parsons Elizabeth Lee-Su this week (10/5): LAC Lab Aaron Homer this week (10/5): LAC Lab Sunday Afternoons 1-4pm Gabriel Neer this week (10/6): Parsons Jeff Brenion this week (10/6): LAC Lab Rene Logan this week (10/6): LAC Lab

Tutors available Sunday evenings 7-12pm Jenny Xu 6-9 this week (10/6): Parsons Eric Flynn 7-10 this week (10/6): Parsons Melissa Federowicz 7-10 this week (10/6): LAC Lab Max Yi 7-10 this week (10/6): LAC Lab Yu-Min Kim 9-12 this week (10/6): Parsons A. Klose 9-12 this week (10/6): Parsons Matt Beaumont-Gay 9-12 this week (10/6): LAC Lab Chris Hwang 9-12 this week (10/6): LAC Lab Monday Evenings 7-12pm Adam Kangas 7-10 this week (10/7): Parsons Ryka Neher 7-10 this week (10/7): Parsons Max Yi 7-10 this week (10/7): LAC Lab Annie Chang 9-12 this week (10/7): Parsons Paul Scott 9-12 this week (10/7): Parsons John McCollough 9-12 this week (10/7): Parsons Alex Pipkin 9-12 this week (10/7): LAC Lab Chris Wottawa 9-12 this week (10/7): LAC Lab Alex Utter 9-12 this week (10/7): LAC Lab

Problem 2 -- Caesar Cipher Encryption strategy Choose an amount to shift your message. Move each letter that amount. message: eorrgb lqvwuxfwlrqv zklfk uhwxuq wr sodjxh wkhlu lqyhqwru shift amount: 3 encrypted message:

Problem 2 -- Caesar Cipher Decryption strategy Shift the encrypted message by every possible shift amount Pick out the English text... eorrgb lqvwuxfwlrqv zklfk uhwxuq wr sodjxh wkhlu lqyhqwru encrypted message: all possible shifts: eorrgb lqvwuxfwlrqv zklfk uhwxuq wr sodjxh wkhlu lqyhqwru fpsshc mrwxvygxmsrw almgl vixyvr xs tpekyi xlimv mrzirxsv gqttid nsxywzhyntsx bmnhm wjyzws yt uqflzj ymjnw nsajsytw hruuje otyzxaizouty cnoin xkzaxt zu vrgmak znkox otbktzux isvvkf puzaybjapvuz dopjo ylabyu av wshnbl aolpy pucluavy jtwwlg qvabzckbqwva epqkp zmbczv bw xtiocm bpmqz qvdmvbwz kuxxmh rwbcadlcrxwb fqrlq ancdaw cx yujpdn cqnra rwenwcxa lvyyni sxcdbemdsyxc grsmr bodebx dy zvkqeo drosb sxfoxdyb mwzzoj tydecfnetzyd hstns cpefcy ez awlrfp esptc tygpyezc nxaapk uzefdgofuaze ituot dqfgdz fa bxmsgq ftqud uzhqzfad xhkkzu ejopnqypekjo sdeyd napqnj pk lhwcqa pdaen ejrajpkn yillav fkpqorzqflkp tefze obqrok ql mixdrb qebfo fksbkqlo zjmmbw glqrpsargmlq ufgaf pcrspl rm njyesc rfcgp gltclrmp aknncx hmrsqtbshnmr vghbg qdstqm sn okzftd sgdhq hmudmsnq bloody instructions which return to plague their inventor cmppez jotusvdujpot xijdi sfuvso up qmbhvf uifjs jowfoups dnqqfa kpuvtwevkqpu yjkej tgvwtp vq rnciwg vjgkt kpxgpvqt

Resources Suppose we have a method that shifts a character c by n letters. char advanceChar(char c, int n) Assume these work... length() (tells the length of a String ) charAt(int n) (returns the n th char of a String ) advanceChar(‘h’, 4) is advanceChar(‘z’, 2) is String s = “more java”; s.length() is s.charAt(2) is s.charAt( ) is ‘v’

High-level plan We have char advanceChar(char c, int n) length() (tells the length of a String ) charAt(int n) (returns the n th char in a String, starting at 0) What to do ?

advanceChar Now we need to worry about making this piece work... public static char advanceChar(char c, int n)

Working with char s _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { } ~ char c = ‘y’; c = (char)(c - 2); c += 5; How do we get back?

Style note // be sure to comment each method you write! public static char advanceChar(char c, int n) // Name: advanceChar // Inputs: a char (c) and an int (n) // Output: the char that is n places // to the right of c, where the // alphabet wraps from ‘z’ to ‘a’.

public static void main(String[] args) { int x = H.in.nextInt(); int y = H.in.nextInt(); int z = confusing(x,y); H.out.println(“z is ” + z); } public static int confusing(int y, int x) { int a = 0; a = 10*y + x; return a; } A message from our sponsor

Problem 1 -- finding e x Please input a power (a double) and I will raise e to that power: 2.5 Enter the number of terms you'd like to use (an int >= 1): 10 The result is Would you like to continue (yes/no)? no Inside main : This is e 2.5 computed using 10 terms of the series x0x0 0! x1x1 1! x2x2 2! x3x3 3! … 4 terms

public static double exp(double x, int numTerms) exp What does exp do? What are x and numTerms referring to?

power public static double power(double base, int p) What does power do? What are base and p referring to?

factorial public static double factorial(int n) What does factorial do? What is n referring to?