Discussion 3. Questions? Term test? Lectures? Labs?

Slides:



Advertisements
Similar presentations
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 3 Numerical Data.
Advertisements

©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Four Defining Your Own Classes.
Logic & program control part 3: Compound selection structures.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 63 – Manipulating Data Using Methods – Day 2.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 2 1 Chapter 2 Primitive.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
©2004 Brooks/Cole Chapter 6 Methods. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Using Methods We've already seen examples of using methods.
Chapter 4 - Control Structures: Part 1 Outline 4.4Control Structures 4.5The if Selection Structure 4.6The if/else Selection Structure 4.7The while Repetition.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 3 Sample Development Loan Calculator.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 6: Odds and Ends  Formatted Output  Random numbers.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Four: Defining Your Own Classes *Instantiable.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes Part 1 Animated.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3 Numerical Data.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: *Sample Development Loan Calculator.
Program design example Task: Develop an algorithm expressed in pseudocode for a specified problem specified problem.
Chapter 2 Getting Started with Java Part B. Topics Components of a Java Program –classes –methods –comments –import statements Declaring and creating.
Chapter Chapter 4 Defining Your Own Classes Part 1.
Chapter 3b Standard Input and Output Sample Development.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: IO *Standard Output *Formatting Decimal.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Sample Development Revisiting the Loan.
Chapter Four Defining Your Own Classes continued.
CS1101X: Programming Methodology Recitation 2 Classes.
CS1101: Programming Methodology Aaron Tan.
Fundamental concepts in Java. Lesson plan Variable declaration, assign statement & practice Design document & practice.
Fruitful functions. Return values The built-in functions we have used, such as abs, pow, int, max, and range, have produced results. Calling each of these.
CS1101: Programming Methodology
Writing Classes (Chapter 4)
Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
Simple Programs from Chapter 2 Putting the Building Blocks All Together (corresponds with Chapter 2)
1 Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
Getting Started with Java Recitation – 1/23/2009 CS 180 Department of Computer Science, Purdue University.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 4 Defining Your Own Classes Part 1 Animated Version.
BCS 2143 Object Oriented Programming Defining Your Own Classes (Part 1)
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
CIS 260: App Dev I. 2 Programs and Programming n Program  A sequence of steps designed to accomplish a task n Program design  A detailed _____ for implementing.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 3 Numerical Data.
Final Exam Review Closed book Closed laptop One sheet of notes permitted SE-0010 Dr. Mark L. Hornick 1.
Computer Programming 2 Lab(1) I.Fatimah Alzahrani.
CS1101X: Programming Methodology Recitation 3 Control Structures.
CS1101X: Programming Methodology Recitation 1 Java Basics Numerical Data.
CS 115 QUIZ # 1 INFORMATION Scheduled for TUESDAY 9/22/15 1.
Discussion 5. Lab 3 Not really using rectangle class Return type of getPoint is String instead of Point You are not able to retrieve the point if you.
CS1101: Programming Methodology Aaron Tan.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 3: Numerical Data Manipulating Numbers Variables.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
CS 106 Introduction to Computer Science I 01 / 31 / 2007 Instructor: Michael Eckmann.
Discussion 4. Labs public MyPoint(double xInit, double yInit ) { MyPoint p = new MyPoint(0, 0); } ClassProblem.java recursive java.lang.StackOverflowError.
Loops (cont.). Loop Statements  while statement  do statement  for statement while ( condition ) statement; do { statement list; } while ( condition.
Chapter 3: Assignment, Formatting, and Interactive Input.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
CS1101X: Programming Methodology Recitation 4 Design Issues and Problem Solving.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 24.1 Test-Driving the Enhanced Car Payment.
Chapter 3 Numerical Data. Objectives After you have read and studied this chapter, you should be able to Select proper types for numerical data. Write.
1 Project 3 String Methods. Project 3: String Methods Write a program to do the following string manipulations: Prompt the user to enter a phrase and.
Strings and I/O. Lotsa String Stuff… There are close to 50 methods defined in the String class. We will introduce several of them here: charAt, substring,
CS1101: Programming Methodology
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
1 1 Chapter 2 Elementary Programming. 2 2 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from.
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
1 Project 4: Computing Distance. 222 Computing Distance Write a program to compute the distance between two points. Recall that the distance between the.
Intro to OOP with Java, C. Thomas Wu Numerical Data
Objectives You should be able to describe: Interactive Keyboard Input
Defining Your Own Classes
Chapter 3 Numerical Data
More on Classes and Objects
CS201 Fall 2016 George Koutsogiannakis
Chapter 2 Primitive Data Types and Operations
EECE.2160 ECE Application Programming
Presentation transcript:

Discussion 3

Questions? Term test? Lectures? Labs?

Labs Indentation of different spaces are used Set the number of spaces of indentation in Dr Java (Edit ->Preference->Miscellaneous->Indent Level) Write the codes all in 1 block (difficult to read) Some lines did not indent properly Code are very similar with your friends (plagiarism?!)

Labs Did not follow the exact format specified in the lab assignment (e.g. Enter length: …) Did not follow the objectives / use syntax which you are not supposed to

Chapter 4 Section 4.11 Slides taken from the book

Problem Statement Problem statement: Write a loan calculator program that computes both monthly and total payments for a given loan amount, annual interest rate, and loan period.

Overall Plan Tasks: Get three input values: loanAmount, interestRate, and loanPeriod. Compute the monthly and total payments. Output the results.

Required Classes LoanCalculator Loan JOptionPanePrintStream inputcomputationoutput

Development Steps We will develop this program in five steps: 1. Start with the main class LoanCalculator. Define a temporary placeholder Loan class. 2. Implement the input routine to accept three input values. 3. Implement the output routine to display the results. 4. Implement the computation routine to compute the monthly and total payments. 5. Finalize the program.

Step 1 Design The methods of the LoanCalculator class MethodVisibilityPurpose startpublicStarts the loan calculation. Calls other methods computePaymentprivateGive three parameters, compute the monthly and total payments describeProgramprivateDisplays a short description of a program displayOutputprivateDisplays the output getInputprivateGets three input values

Step 1 Code Directory: Chapter4/Step1 Source Files: LoanCalculator.java Loan.java Directory: Chapter4/Step1 Source Files: LoanCalculator.java Loan.java Download from

Step 1 Test In the testing phase, we run the program multiple times and verify that we get the following output inside describeProgram inside getInput inside computePayment inside displayOutput

Step 2 Design Design the input routines LoanCalculator will handle the user interaction of prompting and getting three input values LoanCalculator calls the setAmount, setRate and setPeriod of a Loan object.

Step 2 Code Directory: Chapter4/Step2 Source Files: LoanCalculator.java Loan.java Directory: Chapter4/Step2 Source Files: LoanCalculator.java Loan.java

Step 2 Test We run the program numerous times with different input values Check the correctness of input values by echo printing System.out.println("Loan Amount: $" + loan.getAmount()); System.out.println("Annual Interest Rate:" + loan.getRate() + "%"); System.out.println("Loan Period (years):" + loan.getPeriod());

Step 3 Design We will implement the displayOutput method. We will reuse the same design we adopted in Chapter 3 sample development.

Step 3 Code Directory: Chapter4/Step3 Source Files: LoanCalculator.java Loan.java Directory: Chapter4/Step3 Source Files: LoanCalculator.java Loan.java

Step 3 Test We run the program numerous times with different input values and check the output display format. Adjust the formatting as appropriate

Step 4 Design Two methods getMonthlyPayment and getTotalPayment are defined for the Loan class We will implement them so that they work independent of each other. It is considered a poor design if the clients must call getMonthlyPayment before calling getTotalPayment.

Step 4 Code Directory: Chapter4/Step4 Source Files: LoanCalculator.java Loan.java Directory: Chapter4/Step4 Source Files: LoanCalculator.java Loan.java

Step 4 Test We run the program numerous times with different types of input values and check the results.

Step 5: Finalize We will implement the describeProgram method We will format the monthly and total payments to two decimal places using DecimalFormat. Directory: Chapter4/Step5 Source Files (final version): LoanCalculator.java Loan.java

Things you must know for the test 16 September 2006, Saturday, 10am. There are 30 questions: 25 MCQs (multiple-choice questions), and 5 short-answer questions. Maximum score is 35 marks. Open book

Things you must know for the test JOptionPane showMessageDialog showInputDialog String substring length indexOf

Things you must know for the test Date SimpleDateFormat Type Casting (implicit? / explicit?) Wrapper Classes Integer.parseInt( “ 100 ” ) Double.parseDouble( “ 1.0 ” ) etc … DecimalFormat

Things you must know for the test System.out.println / System.out.print Scanner next() nextInt() etc … Math random max pow etc …

Things you must know for the test System.out.println / System.out.print Scanner next() nextInt() etc … Math random max pow etc … GregorianCalendar

Things you must know for the test Classes modifiers(e.g private, public … ) return type parameters Constructors accessors / mutators (getters / setters) actual parameters/formal parameters local variables

Things you must know for the test Operator precedence?

Things you must know for the test

if-then-else op= || && ! ? Operator == String.equals ? Switch break

What else you might want to do? Print API? Rest enough on Friday Read textbook, do exercises at the back Ask questions you are not sure in the forum etc … Get your 35 marks