Practice and Evaluation. Practice Develop a java class called: SumCalculator.java which computes a sum of all integer from 1 to 100 and displays the result.

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts and Debugging.
Program Flow Charting How to tackle the beginning stage a program design.
Program Flow Charting How to tackle the beginning stage a program design.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts, Testing and Debugging.
Chapter 1 Program Design
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
BBS Yapısal Programlama (Structured Programming)1 From problem to program In “real world”… Problem in Natural language Top Down Design in pseudo-code.
Chapter 3 Planning Your Solution
PRE-PROGRAMMING PHASE
Algorithm & Flowchart.
Chapter 1 Pseudocode & Flowcharts
Software Engineering 1 (Chap. 1) Object-Centered Design.
11 Chapter 4 LOOPS AND FILES. 22 THE INCREMENT AND DECREMENT OPERATORS To increment a variable means to increase its value by one. To decrement a variable.
6 Steps of the Programming Process
CSE 1340 Introduction to Computing Concepts Class 2.
The University of Texas – Pan American
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Planning for the Solution
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Programming Lifecycle
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
1 Programming with MATLAB ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Basic problem solving CSC 111.
1 Program Planning and Design Important stages before actual program is written.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
The Art of Programming. The process of breaking problems down into smaller, manageable parts By breaking the problem down, each part becomes more specific.
Chapter 7 Problem Solving with Loops
The Hashemite University Computer Engineering Department
An Introduction to Programming with C++ Sixth Edition
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
WHAT IS THIS? Clue…it’s a drink SIMPLE SEQUENCE CONTROL STRUCTURE Introduction A computer is an extremely powerful, fast machine. In less than a second,
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
Flowcharts C++ Lab. Algorithm An informal definition of an algorithm is: a step-by-step method for solving a problem or doing a task. Input data A step-by-step.
Sequential Processing to Update a File Please use speaker notes for additional information!
Introduction to Computing Systems and Programming Programming.
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.
1 CSE1301 Computer Programming: Lecture 16 Flow Diagrams and Debugging.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
An Introduction to Programming with C++1 An Introduction to Control Structures Tutorial 1.
Chapter 1 Introduction 2nd Semester H
CS1010 Programming Methodology
Introduction to programming
Chapter 2- Visual Basic Schneider
The Software Development Cycle
Lecture 2 Introduction to Programming
Programming Problem steps must be able to be fully & unambiguously described Problem types; Can be clearly described Cannot be clearly described (e.g.
SME1013 PROGRAMMING FOR ENGINEERS
Chapter 2- Visual Basic Schneider
Coding Concepts (Basics)
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
SME1013 PROGRAMMING FOR ENGINEERS
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming Fundamentals (750113) Ch1. Problem Solving
Flowcharts and Pseudo Code
Programming Fundamentals (750113) Ch1. Problem Solving
WJEC GCSE Computer Science
CHAPTER 6 Testing and Debugging.
The Software Development Cycle
Presentation transcript:

Practice and Evaluation

Practice Develop a java class called: SumCalculator.java which computes a sum of all integer from 1 to 100 and displays the result to the screen

Problems with practice exercise Problem solving skill: –Recognize and understand problems –Develop an algorithm –Coding Java syntax –Translate from algorithm to code –Practice. Practice. Practice

Flowchart and Algorithm - a computer is only a problem-solving tool! - Java is one tool used to solve problems

Method of Problem Solving Recognize and understand the problem. Accumulate facts. Select appropriate theory. Make necessary assumptions. Solve the problem. Verify results.

Method of Problem Solving Develop an Algorithm. Write the program in a computer language. (i.e. in C, Java etc) Enter the program into the computer. Test and debug the program. Run the program, input data, and get the results from the computer.

Algorithm and Flowchart An Algorithm is just a detailed sequence of simple steps that are needed to solve a problem. A Flowchart is a graphical representation of an algorithm.

Algorithm (Week 3 practice) Develop a java class called: SumCalculator.java which computes a sum of all integers from 1 to 100 and displays the result to the screen Step 1: Understand the problem: Computes a sum of all integers from 1 to 100 Step 2: What is the input? Step 3: What is the output? Start from 1, stop if reach 100 or (1 and 100) Sum

Algorithm Step 4: How do we compute the output? (first solution) Step 4.1: Start with the current integer: 1 Step 4.3: Add the current integer to Sum Step 4.2: Sum starts with 0 Step 4.4: If the current integer is less than 100, keep on adding the current integer to sum and increase It by 1(i.e, go back to 4.3). Step 4.5:Otherwise, print out the sum

Algorithm StartStop Sequential steps Condition/ Decision

Flowchart Step 4.3: Add the current integer to Sum Step 4.1: Start with the first integer: 1 Step 4.2: Sum starts with 0 Step 4.4: If the current integer is less than 100, go to next integer and keep on adding the current integer to sum (i.e, go back to 4.3). Step 4.5:Otherwise, print out the sum Stop Current Integer=1 Sum=0 Sum = Sum + Current Integer < 100 Increase Current Integer by 1 Print Sum Start

Practice Step 4 (second solution): sum = 100*(100+1)/2

Testing a program Ideal: Test cases should be designed BEFORE writing the code Practice: Test cases are only designed AFTER the code is written Time to write codes <= Time to test

What should we test Philosophy: –Test everything that could reasonably break. For example: Test if the inputs received from a user is valid Test if the computation is done correctly

How to develop a test case A test case is a document that contains - test case id - description of what this test case is - an input, - an action, or event and - an expected response to determine if a feature of an application is working correctly.

Example Test Case Id: Testcase01 Description: Testing if the program exits when an invalid number of weeks is entered Input: an integer represents a number of weeks and is outside of [1..12] Expected response: the program will display a message and exit

Testing Amortization.java Please test the Amortization.java in (c), (d) and (e) following the test cases given

Practice -Modify the existing SumCalculator.java program to print out the average:

Practice Develop a class called PrintEven to print only even integers from 1 to 100 Modify the existing PrintEven to print only even integers from 1 to n. Allow a user to enter the value for n.

Check list Make sure comments are included in LoanCalculator.java Make sure that the directories are created, classes and java files are copied according to the requirements of the project Make sure to copy the design document (zip files), or submit your project on floppy disk or CD on time

Practice Write the code ComputeMin to print out the minimum of three integers. Three integers are inputs from a user Reuse the code ComputeMin to develop ComputeMax which prints out the maximum of three integers. Three integers are inputs from a user

Practice Develop a class call PrimeNumber that: –Get an integer as input from users –If the integer is a prime number, print out a message that says: Prime number –If not, print out a message that says: It is not a prime number

Algorithm Run a for loop that tests to see if any number from 2 up to sqrt(n) divides evenly into the given number. If you find one, then the number isn't prime. If you don't find one, the number is prime.