CS1101: Programming Methodology
Week 3: Numerical Data and OOP Basics Last week: Chapter 1: Intro to OOP and S/W Development Chapter 2: Getting Started with Java DrJava CourseMarker This week: Take-home lab #1 Chapter 3: Numerical Data Chapter 4: Defining Your Own Classes – Part 1 Next week: Chapter 4: Defining Your Own Classes – Part 1 (cont’d) Chapter 5: Selection Statements © CS1101 (AY Semester 1)Week3 - 2
Reminder Have you read the relevant chapters and PowerPoint files BEFORE coming to this lecture? Have you been filling your Progress Chart? © CS1101 (AY Semester 1)Week3 - 3
Chapter 3 Numerical Data Any questions on Chapter 3? We’ll skip GregorianCalendar class. © CS1101 (AY Semester 1)Week3 - 4
What are the answers? (1/2) (int) = 30 % 7 = 30 / 7 = 30.0 / 7 = 30 / 7.0 = 30.0 / 7.0 = (double) 30 / 7 = 30 / (double) 7 = (double) (30 / 7) = © CS1101 (AY Semester 1)Week
What are the answers? (2/2) "Java" = "Java" = "Java" + ( ) = 1 + "Java" = "Java" + 3 = © CS1101 (AY Semester 1)Week
Temperature Conversion The following is the formula to convert temperature in degree Fahrenheit to Celsius: C = (5/9) × (F – 32) Download “Ch3TemperatureConvert.java” and test it. Why doesn’t it work? Can you correct the program? Note: This type of error is very common! © CS1101 (AY Semester 1)Week3 - 7
Loan Calculator Let’s study the development of this program. © CS1101 (AY Semester 1)Week3 - 8
Take-home lab assignment #1 It has been released. Deadline is next Monday, 31 August 2009, 23:59hr. Any questions? © CS1101 (AY Semester 1)Week3 - 9
Java API Documentation (1/2) A very important website © CS1101 (AY Semester 1)Week Bookmark it!
Java API Documentation (2/2) It’s impossible to cover everything about a standard (built-in) class, so you need to look it up yourself. For example, in take-home lab #1, you need to look for these yourself: Exercise 1: What is the maximum integer value in Java? Exercise 3: What is the method in Scanner class to read the user’s input as a line of text? Exercise 4: What is the appropriate method in Math class to compute the hypothenuse? © CS1101 (AY Semester 1)Week3 - 11
Chapter 4 Defining Your Own Classes – Part 1 Let’s go to Chapter 4. © CS1101 (AY Semester 1)Week3 - 12
Summary for Today What are numerical data types? Performing computation on numerical data Some standard (built-in) classes DecimalFormat Scanner Math Random API documentation page How to define and use your own class (to be continued next week) © CS1101 (AY Semester 1)Week3 - 13
Announcements/Things-to-do Take-home lab #1 deadline: 31 August 2009, Monday, 23:59hr. To prepare for next week’s lecture: Read Chapter 4 (again) and Chapter 5 and their PowerPoint files before you come for lecture. Do Quick Check questions in Chapter 4. Check out the answers (on CS1101 website) yourself. To prepare for next week’s discussion session: Download “week4_discussion_qns.pdf” from module website, “CA – Discussion”. Do the questions before you attend your discussion session. © CS1101 (AY Semester 1)Week3 - 14
End of File © CS1101 (AY Semester 1)Week3 - 15