Software Development Method Reference : Problem Solving & Program Design in C ; Jeri R.Hanly, Elliot...

Post on 04-Jan-2016

239 views 1 download

Tags:

transcript

Software Development Method

Reference : Problem Solving & Program Design in C ; Jeri R.Hanly, Elliot B.Koffman

Software Development Method

1. Specify the problem requirements2. Analyze the problem3. Design the algorithm to solve the

problem4. Implement the algorithm5. Test and verify the completed program6. Maintain and update the program

Problem

Specifying the problems requirement forces you to state the problem clearly and unambiguously and to gain a clear understanding of what is required for its solution.

Objective – To eliminate unimportant aspects and zero in on the root problem.

Analysis

Analyzing the problem involves identifying the problem inputs,that is,the data you have to work withoutputs,that is,the desired resultsany additional requirements or constraints on

the solution

Analysis

At this stage, you should also determine the required format in which the results should be displayed

Develop a list of problem variables and relationships

These relationships may be expressed as formulas

Analysis

If steps 1 and 2 are not done properly,you will solve the wrong problem.

Read the problem statements carefully ,first,to obtain a clear idea of the problem

And second, to determine the inputs and outputs.You may find it helpful to underline phrases in the problem statement that identify the inputs and outputs,as in the problem statement below.

Analysis

Compute and display the total cost of apples given the number of pounds of apples purchased and the cost per pound of apples.

Next,summarize the information contained in the underlined phrases :

Analysis

Problem Input

quantity of apples purchased (in pounds)

cost per pound of apples (in dollars per pound)

Problem Output

total cost of apples (in dollars)

Analysis

Once you know the problem inputs and outputs, develop a list of formulas that specify relationships between them.The general formula

Total cost=Unit cost X Number of units

Analysis

computes the total cost of any item purchased.Substituting the variables for our particular problem yields the formula

Total cost of apples =

Cost per pound X Pounds of apples

Design

Designing the algorithm to solve the problem requires you to develop a list of steps called an algorithm to solve the problem and then verify that the algorithm solves the problem as intended.

algorithm = a list of steps for solving a problem

Design

Algorithm for a Programming Problem1. Get the data

2. Perform the computations

3. Display the results Algorithm can be presented either using

pseudocode or flowchart.

Implementation

Implementing the algorithm involves writing it as a program.

You must convert each algorithm step into one or more statements in a programming language.

Testing

Testing and verifying the program requires testing the completed program to verify that it works as desired.

Run the program several times using different sets of data,making sure that it works correctly for every situation provided for in the algorithm.

Case Study 1

Problem

You and your three friends plan to go for shopping around KL. There are 3 ways to go there. Your options are between LRT, taxi or bus. Due to heavy traffic congestion, you and your friends decided to choose transport which is fast but convenient. Write a program to calculate the chosen transport fare.

Analysis Choose LRT - Why ? It save time and cost Problem Input - Number of passenger and LRT fare Problem Output - LRT fare according to number of

passenger and destination Relevant Formula =

LRT fare X number of passenger Relevant data –

LRT fare to :Bukit Bintang = RM 1.60Bandaraya = RM 1.40PWTC = RM 2.20

Design

1. Get number of passenger and destination.

2. Calculate the LRT fare by performing below computation :

LRT fare X number of passenger

3. Display LRT fare in Ringgit Malaysia(RM)

Implementation

Program…..

Testing

Test the program by inserting different number of passenger and locations.

Case Study 2

Problem

Your summer surveying job requires you to study some maps that gives distances in kilometers and some that use miles. You and your coworkers prefer to deal in metric measurements. Write a program that performs the necessary conversion.

Analysis The problem states that you prefer to deal in metric

measurements, so you must convert distance measurements in miles to kilometers Problem Inputmiles # the distance in miles

Problem Outputkms # the distance in kilometers

Relevant Formula1 mile = 1.609 kilometers

Design

1. Get the distance in miles.

2. Convert the distance to kilometers. The distance in kilometers is 1.609 times the

distance in miles.

3. Display the distance in kilometers

Implementation# Converts distance in miles to kilometers # Conversion constantKMS_PER_MILE = 1.609 # Input distance in milesmiles = 0 # Output distance in kilometerskms = 0 # Get the distance in milesprint "Enter the distance in miles",miles = input(":") # Convert the distance to kilometerskms = KMS_PER_MILE * miles # Display the distance in kilometersprint "That equals ", kms

Testing

Distance of 10.0 miles is converted to 16.09 kilometers, as it should be. Test the program by inserting other different value of distance.