Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Introduction to Programming and Software Development CMPCD1017 Session 3:Requirements Analysis and Specification, Cont’d."— Presentation transcript:

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

2 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 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 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 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 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 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 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 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 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 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 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 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 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 15 Case Study IF Overall Mark < 40 Display Pass Details Display Fail Details Get Student I.D. True False Finish

16 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 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 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.


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

Similar presentations


Ads by Google