E01 C Programming and Software Engineering

C programming and SW engineering  Example Application of Software Development Process

The  following  gives you   an   example   on  how  to complete a software project by following the Software Development Process (SDP) step by step. This is also what you

should follow to write up your assignment reports.

Example: (for each assignment, you will be given an assignment sheet similar to this)

Write a C program which takes a depth into the earth, given in units of kilometers, as the input data and compute and display the corresponding temperature at this particular depth in two formats, namely, degrees Celsius and degrees Fahrenheit. The relevant formulas

are given as follows:

. Temperature in degrees Celsius given the depth in kilometers: Celsius = 10 * depth + 20

. Temperature in degrees Fahrenheit is obtained by converting temperature in degrees Celsius:

Fahrenheit = 9/5 * Celsius + 32

Software Development Process

1)  Problem statement:

In this part, your job is to fully understand the requirements of this project, as proposed by the user of this software (your customer) so that all the functionalities this software needs to provide are clearly understood and stated. Given the above example, you may list all the

functionalities this program should offer as follows:

1)   Provide an interface through which the user can input a number which is a real number

and represents a legal depth in kilometers.

2)   The execution of the program will be terminated if an illegal input is detected. Being

illegal maybe defined as follows:

. The input depth is out of the legal range (if we know the legal range and, here, it is left out of our considerations for simplicity).

. The input contains non-numerical characters.

3)   The program should display two outputs: degrees Celsius and degrees Fahrenheit. These two temperatures should have an accuracy of 2 digits after the decimal point (Note: the original statement did not specify this, common sense is applied by the programmer  and  agreed with  the  customer  following production  of the  problem

statement).

4)   The program exits.

2)  Analysis

In this part, your job is to analyze all the requirements listed in above section to decide the entire software architecture and chose the best data structure as well as the most suitable

algorithm.

For the example at hand, it is clear that we need to deal with the Input/Output and turn the

mathematical equations into C codes.

. On an input:

Firstly, a message needs to be printed on the screen to let the users know what data/action  this  program  expects.  Because  the  execution  is  terminated  upon  the detection of an illegal input, we can specify the desired data type in the c code used to

read the input off the keyboard.

你可能感兴趣的:(学习方法)