Introduction to Programming and Software Development CMPCD1017 Session 3:Requirements Analysis and Specification, Cont’d.

Slides:



Advertisements
Similar presentations
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 5: Program Logic and Indefinite Loops.
Advertisements

CSE 1301 Lecture 6B More Repetition Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
Copyright 2008 by Pearson Education Building Java Programs Chapter 3: Parameters, Return, and Interactive Programs Lecture 3-3: Interactive Programs w/
Introduction to Computers and Programming Lecture 8: More Loops New York University.
Introduction to Computer Programming Looping Around Loops I: Counting Loops.
18 File handling1June File handling CE : Fundamental Programming Techniques.
Introduction to Computer Programming Loops N Decisions If/Else Counting Loops.
School of Computing Science CMT1000 Ed Currie © Middlesex University Lecture 4: 1 CMT1000: Introduction to Programming Ed Currie Lecture 5a: Input and.
Copyright 2008 by Pearson Education Building Java Programs Chapter 4 Lecture 4-1: Scanner ; if/else reading: , 4.2, 4.6.
Copyright 2008 by Pearson Education Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: self-check: #16-19.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 3: Parameters, Return, and Interactive Programs with Scanner.
Copyright 2008 by Pearson Education Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: self-check: #16-19.
1 Scanner objects. 2 Interactive programs We have written programs that print console output. It is also possible to read input from the console.  The.
Topic 11 Scanner object, conditional execution Copyright Pearson Education, 2010 Based on slides bu Marty Stepp and Stuart Reges from
Introduction to Programming and Software Development CMPCD1017 Session 2:Requirements Analysis and Specification.
Methods (Functions) CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Java Programming: From the Ground Up
The while Loop Syntax while (condition) { statements } As long condition is true, the statements in the while loop execute.
The while Loop Syntax while (condition) { statements } As long condition is true, the statements in the while loop execute.
Repetition & Loops. One of the BIG advantages of a computer: ­It can perform tasks over and over again, without getting bored or making mistakes (assuming.
Loops (While and For) CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Methods (a.k.a. Functions)
1 while loops. 2 Definite loops definite loop: A loop that executes a known number of times.  The for loops we have seen so far are definite loops. We.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
CSC Programming I Lecture 6 September 4, 2002.
CHAPTER 5 GC 101 Input & Output 1. INTERACTIVE PROGRAMS  We have written programs that print console output, but it is also possible to read input from.
Programming with Loops. When to Use a Loop  Whenever you have a repeated set of actions, you should consider using a loop.  For example, if you have.
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Cumulative algorithms. 2 Adding many numbers How would you find the sum of all integers from ? // This may require a lot of typing int sum = 1 +
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC141 Computer Science I 2/4/20161.
1 BUILDING JAVA PROGRAMS CHAPTER 5 PROGRAM LOGIC AND INDEFINITE LOOPS.
Building Java Programs Chapter 4 Lecture 4-1: Scanner ; cumulative algorithms reading: 3.3 – 3.4, 4.2.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Common Mistakes with Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Building Java Programs
Exceptions and User Input Validation
Building Java Programs
Introduction to Methods in java
Selected Topics From Chapter 6 Iteration
Topic 11 Scanner object, conditional execution
Building Java Programs
Control Statement Examples
Building Java Programs
Building Java Programs
Building Java Programs
Introduction to Computer Programming
Python programming exercise
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Chapter 4 Lecture 4-1: Scanner; if/else reading: 3.3 – 3.4, 4.1, 4.5
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.
Building Java Programs
Building Java Programs
Presentation transcript:

Introduction to Programming and Software Development CMPCD1017 Session 3:Requirements Analysis and Specification, Cont’d

2 Content Session 2 Tutorial Feedback  Task 1 – Test Data Effects  Task 2 – Model Answer and Further Analysis Requirements Analysis and Specification  Iterative Phase in a Sequential Process  Signing Off Case Study

3 Session 2 Tutorial Feedback Task 1Test Data  Correct Data Example Name: Joe Year of Birth: 1986 Current Year: 2004 Produces “Hello Joe, your approximate age is 18”  Incorrect ‘Year of Birth’ Data Example Year of Birth: Produces “Hello Joe, you approximate age is ”

4 Session 2 Tutorial Feedback Task 1 Test Data  Incorrect ‘Year of Birth’ Data Example 2 Year of Birth: 19x86 Produces Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at session2.main(session2.java:19)

5 Session 2 Tutorial Feedback We can see that data has a direct effect upon the execution of a program and like in this case, even crash it.  In this case the user entered invalid data, which raises an important point – We must always assume the user will make a mistake  We will be looking at validating user input later in the module. The next few lectures after this will be focusing upon testing and test data.

6 Session 2 Tutorial Feedback Task 2  This specification is predominantly ‘functional requirements’  Functional Requirements A module marks system  Before student exam and coursework marks are entered, the user must enter the exam to coursework ratio  The ratio is to be entered as two numbers which must add up to 100, i.e. a 75% exam and 25% coursework module would be represented by entering 75 as the exam part of the ratio and 25 as the coursework part of the ratio. If the ratio data does not add up to 100 then the user must enter the ratio numbers until they do.  Once the ratio is successfully entered, the user can proceed to enter each students exam and coursework marks, along with a student i.d. to uniquely identify each student  Student I.D.6 Alpha-Numeric Characters  ‘XXXXXX’ used as end of data input signifier  Coursework Mark3 Digit Integer  Max Value 100, Min Value 0  Exam Mark3 Digit Integer  Max Value 100, Min Value 0

7 Session 2 Tutorial Feedback Task 2  Functional Requirements A module marks system  As each pair of exam and coursework marks are entered for each student, the system must calculate the overall module mark for that student and if the overall mark is less that 40 display  The Student I.D, the word ‘Fail’ and the overall mark  Else the mark will be 40 or greater in which case the system will display  The Student I.D., the word ‘Pass’ and the overall mark  Once the student exam and coursework marks have been entered the system must output average of the  Coursework Marks  Exam Marks  Overall Marks  Non-Functional Requirements The system must be text-based as the school only has text-based computer terminals.

8 Session 2 Tutorial Feedback Task 2  Further Analysis How will the user signify they wish to quit the program during the exam to coursework ratio data input phase? A student’s overall mark has the possibility of being a floating point number. What number of decimal places is required?  The same question must be asked for all of the averages. How should the system react to the user entering an invalid student i.d., coursework or exam mark? What possible solutions to these questions can you think of to put forward to the customer for them to choose from?

9 Requirements Analysis and Specification We can see from Task 2 that when a ‘Requirements Specification’ is created, it must be further analysed to find possible omissions and other anomylies. While we may be following a sequential process model, each phase may be iterative. The goal of this phase is to complete a Requirements Specification that is ‘signed off’ by the customer.

10 Requirements Analysis and Specification If we do not get the ‘Requirements Specification’ signed off, the customer can, legally ask for more functional and non-functional requirements to be added or original ones updated.  If this happens at the design phase, it could mean a complete re- design of a solution.  If this happens at the coding stage, it could mean a complete re- design as well as the dumping and/or update of current code Updating/Maintaining code increases the possibility of bugs in the system, requiring further maintenance later on. Not getting a requirements specification signed off will cost the loss of time and money for work already done and an increase in time and money putting it right.

11 Case Study This case study focuses upon one of the requirements from task 2 of the session 2 tutorial: The Student Marks data input and Pass/Fail information output. Due to this part of the system requiring the coursework to exam ratio to be set by the user before the marks can be entered, we will assume this has been set to 25% coursework and 75% exam.

12 Case Study The Requirements for this part of the system are:  Once the ratio is successfully entered, the user can proceed to enter each students exam and coursework marks, along with a student i.d. to uniquely identify each student Student I.D.6 Alpha-Numeric Characters ‘XXXXXX’ used as end of data input signifier Coursework Mark3 Digit Integer Max Value 100, Min Value 0 Exam Mark3 Digit Integer Max Value 100, Min Value 0  As each pair of exam and coursework marks are entered for each student, the system must calculate the overall module mark for that student and if the overall mark is less that 40 display The Student I.D, the word ‘Fail’ and the overall mark  Else the mark will be 40 or greater in which case the system will display The Student I.D., the word ‘Pass’ and the overall mark

13 Case Study This case study introduces you to two further programming constructs, following on from the ‘sequential’ construct highlighted by task 1 in the session 2 tutorial.  Iteration This is highlighted in the requirements twice  The plural nature of ‘enter each students exam and coursework marks’  ‘As each pair of exam and coursework marks are entered for each student ’  Selection This is highlighted in the requirements by  ‘if the overall mark is less that 40’, and  ‘Else the mark will be 40 or greater’

14 Case Study Textual Design 1. Get Student I.D. 2. While Student I.D. is not ‘XXXXXX’ 1. Get Student Marks 2. Calculate Overall Mark 3. If Overall Mark is less than Display Fail Details 4. Else 1. Display Pass Details 5. Get Student I.D. 3. End Loop Start Get Student I.D. IF Student I.D. = “XXXXXX” Get Student Marks Calculate Overall Mark 2 False 31 True

15 Case Study IF Overall Mark < 40 Display Pass Details Display Fail Details Get Student I.D. True False Finish

16 Case Study import java.util.*; public class session3 { public static void main(String[] args) { // Set-up data input and declare variables String student_id; int coursework_ratio = 25, exam_ratio = 75; float coursework_mark, exam_mark; float overall_mark; Scanner data_input = new Scanner(System.in); // Get Student ID System.out.print("Please enter the Student I.D.: "); student_id = new String(data_input.next()); while(! student_id.equals("XXXXXX")) { // Get student coursework mark System.out.print("Please enter the coursework mark: "); coursework_mark = data_input.nextInt(); // Get student exam mark System.out.print("Please enter the exam mark: "); exam_mark = data_input.nextInt();

17 Case Study // Calculate overall mark overall_mark = ((coursework_mark*coursework_ratio)/100) + ((exam_mark*exam_ratio)/100); System.out.printf("Overall = %f%n", overall_mark); if (overall_mark < 40) { System.out.printf("%s, Fail, %.2f%n%n", student_id, overall_mark); } else { System.out.printf("%s, Pass, %.2f%n%n", student_id, overall_mark); } // Get Student ID System.out.print("Please enter the Student I.D.: "); student_id = new String(data_input.next()); } // Wait for the return key to be pressed System.out.print("Type 'OK' and press Return to continue: "); student_id = new String(data_input.next()); }

18 Tutorial Task 1  Type in the code and test it like you tested the code in Session 2, i.e. correct and incorrect data.  Think about testing the ‘Pass’ and ‘Fail’ element of the system in particular. Task 2  The customer requires that you update the requirements specification for the student marks system Instead of simply categorising Pass ad Fail, the customer wants the following categories based upon the overall mark:  70% or moreA40.00% to 49.99%D  60.00% to %B30.00% to 39.99%E  50.00% to 59.99%C29.99% or lessF  Have a go at updating the design to take into account these new marks categories. A model answer will be given in the next session.